Skip to main content

LABRAT, Remote Automated Testing

A universal interface for lab automation

Let the rat run the maze.

Control oscilloscopes, signal generators, VNAs, spectrum analysers, power supplies, cameras and more through one API.

CI Licence

Quick start · Install · API · MCP · Drivers · Contributing

labrat in a terminal: the devices, a voltage set, a supply described with its live values and limits, a refused value, and stop

Quick start

pipx install git+https://github.com/reinhardjvv/labrat.git
labrat demo                       # start a demo lab with simulated instruments

In a second terminal, with the token the demo prints:

export LABRAT_URL=http://127.0.0.1:8780 LABRAT_TOKEN=<token>
labrat describe psu
labrat shell                      # an interactive prompt with tab completion

Connect Claude, or any MCP client, to the same lab:

claude mcp add labrat -e LABRAT_URL=$LABRAT_URL -e LABRAT_TOKEN=$LABRAT_TOKEN -- labrat mcp

Every client sends the same message, so curl works too:

curl -s $LABRAT_URL/api/v1/message -H "Authorization: Bearer $LABRAT_TOKEN" \
     -d '{"op": "set", "device": "psu", "name": "VoltageLevel", "channel": "1", "value": 5}'

Ask your agent

With LABRAT connected over MCP, Claude or another agent works the bench the way a person would:

Start an experiment called filter-check. Sweep the generator from 1 to 20 MHz in 1 MHz steps, take a scope
trace at each step, and tell me where the response is 3 dB down.

The agent finds the instruments, locks them, opens an experiment in your folder, runs the sweep and reads its own data back. The lab's limits, locks and approvals apply to every request, and every command is logged under the agent's token. Give it as much freedom as you want (MCP).

The nest and the rats

A lab has one nest and any number of rats. The nest is the server everyone talks to. It holds the tokens, the limits, the locks and the audit log. The rats sit at the benches next to the equipment, and each one serves whatever is plugged into it. A rat can be any Linux computer, from a single-board computer to the PC already beside an instrument, or a microcontroller that speaks the rat protocol. A small lab can run the nest alone, with its devices plugged straight in.

flowchart TB
    clients["<b>clients</b><br/>Python · MATLAB · curl"] -- HTTP --> nest
    agents["<b>AI agents</b><br/>Claude and others"] -- MCP --> nest
    nest["<b>nest</b><br/>central server"]
    nest --> rat1["<b>rat</b> · bench PC<br/>scopes · supplies"]
    nest --> rat2["<b>rat</b> · Raspberry Pi<br/>cameras · SLMs"]
    nest --> rat3["<b>rat</b> · ESP32<br/>relays · sensors"]
    nest --> store[("<b>storage</b><br/>NAS or disk")]

What it works with

Equipment Connected by
Oscilloscopes, signal and function generators, VNAs, spectrum analysers, power supplies, multimeters, source meters and other bench instruments Ethernet, USB or RS-232, through their standard SCPI commands
Cameras: USB webcams, PoE and network cameras, machine-vision cameras such as Allied Vision, Basler and FLIR USB, RTSP, MJPEG, GigE Vision or USB3 Vision
Spatial light modulators, DMDs and projectors HDMI
Relays, shutters, interlocks, switches and sensors GPIO pins on a rat
Sensors, ADCs, DACs and port expanders I2C on a rat
Pumps, stages, controllers and Arduino boards with their own commands serial, or a serial server on the network
Smart lights and plugs, ESP32 boards and anything on a broker or a web API MQTT or HTTP
Uninterruptible power supplies Network UPS Tools
Anything else with a programming interface a driver of a few dozen lines of Python

A bench instrument needs no code. Its commands go in a few lines of configuration (drivers), and simulated devices let you try everything without hardware.

Use it from

Python Client().set("bench-rat/psu", "VoltageLevel", 3.3, channel="1") (clients)
MATLAB webwrite with a bearer token, or examples/matlab/labrat.m (clients)
AI agents claude mcp add labrat -- labrat mcp (MCP)
Anything else one HTTP endpoint and JSON (message API)

Set up a lab

Step Where Command
1 the server sudo ./packaging/install.sh nest (install)
2 each bench computer sudo ./packaging/install.sh rat (install)
3 anywhere labrat find lists the rats on the network
4 anywhere labrat adopt <rat> adds one to the nest, with the key the rat shows

Any 64-bit Linux runs a nest or a rat. Good defaults are Ubuntu Server LTS or Debian for the nest, and Raspberry Pi OS Lite (64-bit), DietPi or Armbian for rats on single-board computers (which computer and which OS).

Questions

Does it replace PyVISA, LabVIEW or my scripts? No. LABRAT sits between them and the equipment, so every script, notebook and agent sees the same instruments through the same limits and locks. LabVIEW and MATLAB talk to it over HTTP.

Do I need a Raspberry Pi? No. A small lab runs the nest alone on one computer, with its instruments on the network or plugged in. Rats are for equipment that is spread over benches or needs local USB, GPIO or I2C.

Is it safe to let an agent drive real equipment? The guardrails are yours to set: limits on every setting, locks, requests that wait for a person, and one stop that puts the whole lab in its safe state. A rat that loses the nest does the same by itself.

Is there a web dashboard? Not yet. The terminal, the Python client and MCP cover everything today, and a dashboard will use the same API.

Can two people use the same instrument? Not at the same time, if they lock it. labrat lock makes a device yours until you let go, labrat who shows who holds what, and require_lock makes a lock necessary before any change. People are added with labrat user add, with no restart.

Where does my data go? Wherever you point it: a local disk or a NAS, in a folder per person and experiment (experiments).

Documentation

Architecture the nest, rats, messages and how they find each other
Install hardware, operating systems, the nest and the rats
Configuration nest.toml, rat.toml, devices, limits and tokens
Message API every operation, error code and route
Rat protocol what firmware must do to be a rat, for ESP32 and other boards
Clients Python, MATLAB, curl, JavaScript and LabVIEW
MCP AI agents through the Model Context Protocol
Drivers the built-in drivers and how to write one
Recordings readings, waveforms and streams written to storage on a schedule
Experiments each person's work in their own folder, with its commands, settings, notes and recordings
Names and selectors ids, identities, the standard kinds, and finding devices by type, maker or serial
Safety and security limits, safe states, the watchdog, tokens and the network
Roadmap what comes next

Contributing

Drivers, client libraries, documentation and bug reports are all welcome. CONTRIBUTING.md explains the workflow and the house rules. A maintainer reviews every pull request, with an automated review as advice on branches of this repository. Report security issues privately, as SECURITY.md describes.

Licence

LABRAT is released under the Apache License 2.0.

Metadata

Release files for labrat-lab 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labrat-lab 0.1.0
File Size Uploaded Provenance Actions
labrat_lab-0.1.0.tar.gz 107.2 kB With provenance Details for labrat_lab-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for labrat-lab 0.1.0
File Interpreter ABI Platform Actions
labrat_lab-0.1.0-py3-none-any.whl Python 3 none any Details for labrat_lab-0.1.0-py3-none-any.whl

Total release size: 210.1 kB

Release files / labrat_lab-0.1.0.tar.gz

Download URL labrat_lab-0.1.0.tar.gz
Size 107.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e1e231bc807e86778a11a434a9cd27df3b69a3ae408e4feb0110ee1b0b017af
BLAKE2b-256 checksum
How to use checksums
43c1ef29706ee6dc603ca8c58be19ae90b81edfc463773fdcc9cefe8c65bbbe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / labrat_lab-0.1.0-py3-none-any.whl

Download URL labrat_lab-0.1.0-py3-none-any.whl
Size 102.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84757bdbee5d3e2d63ad4eebc90434e1b65725a6f9130660d9f1bb35fde140ac
BLAKE2b-256 checksum
How to use checksums
35124c890e229b75540c8249f6c0c4852867a6093962b6954ce4be1d603facfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for labrat-lab 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for labrat_lab-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page