Getting Started
This tutorial walks you through installing mcgpib, connecting to an AR488 bridge, and discovering the instruments on your GPIB bus. By the end, you will have a working MCP server that an LLM can use to talk to your test equipment.
What you will need
Section titled “What you will need”Before starting, make sure you have:
- An AR488 bridge — an ESP32 running AR488 firmware with a GPIB connector and SN75160/SN75161 bus drivers
- A connection to the bridge — USB cable (serial) or WiFi network (TCP)
- At least one GPIB instrument — a multimeter, oscilloscope, power supply, or any IEEE-488 device connected to the bus with a GPIB cable
- Python 3.11+ with uv installed
- Claude Code (or another MCP-compatible client)
Install mcgpib
Section titled “Install mcgpib”-
Quickest: run directly from PyPI
If you just want to use mcgpib without cloning the source,
uvxwill fetch and run it in an isolated environment:Terminal window uvx mcgpibThis downloads mcgpib, installs its dependencies, and starts the MCP server. Press
Ctrl+Cto stop it. You will configure it properly in the next step. -
Alternative: install from source
If you want to modify mcgpib or run from a local checkout:
Terminal window git clone https://git.supported.systems/warehack.ing/mcgpib.gitcd mcgpibuv syncuv run mcgpib
Configure your bridge
Section titled “Configure your bridge”mcgpib reads its configuration from a TOML file. It searches these locations in order:
- The path in the
$MCGPIB_CONFIGenvironment variable ./mcgpib.tomlin the current directory~/.config/mcgpib/config.tomlin your home directory
Create a configuration file for your setup. The examples below show the two transport types.
Create ~/.config/mcgpib/config.toml:
[server]log_level = "INFO"
[[bridge]]name = "bench-a"transport = "serial"port = "/dev/ttyUSB0"baudrate = 115200auto_scan = trueauto_identify = trueread_timeout_ms = 3000inter_command_delay_ms = 10Each field:
| Field | Purpose |
|---|---|
name | A unique identifier you choose for this bridge. Used in every tool call. |
transport | "serial" for USB connections. |
port | The serial port path. On Linux this is typically /dev/ttyUSB0 or /dev/ttyACM0. On macOS, look for /dev/cu.usbserial-*. |
baudrate | Must match the AR488 firmware setting. The default is 115200. |
auto_scan | When true, mcgpib scans the bus for instruments immediately after connecting. |
auto_identify | When true, sends *IDN? to each discovered listener during a scan. |
read_timeout_ms | How long to wait for an instrument response before timing out (milliseconds). |
inter_command_delay_ms | Pause between consecutive commands. Prevents ESP32 voltage dips under rapid bus activity. |
Create ~/.config/mcgpib/config.toml:
[server]log_level = "INFO"
[[bridge]]name = "bench-a"transport = "tcp"host = "192.168.1.50"tcp_port = 23auto_scan = trueauto_identify = trueread_timeout_ms = 5000inter_command_delay_ms = 20The WiFi-specific fields:
| Field | Purpose |
|---|---|
host | IP address of the ESP32 on your network. Configure this on the bridge first with the ++wifi command over serial. |
tcp_port | TCP port the bridge listens on. The AR488 WiFi default is 23. |
Note the longer timeouts — WiFi adds latency compared to USB, so read_timeout_ms = 5000 and inter_command_delay_ms = 20 give the bridge more breathing room.
Add to Claude Code
Section titled “Add to Claude Code”Register mcgpib as an MCP server so Claude Code can discover and call its tools.
claude mcp add mcgpib -- uvx mcgpibclaude mcp add mcgpib -- uv run --directory /path/to/mcgpib mcgpibReplace /path/to/mcgpib with the actual path to your cloned repository.
If your config file is not in one of the default search paths, point mcgpib to it with the environment variable:
MCGPIB_CONFIG=/path/to/mcgpib.toml claude mcp add mcgpib -- uvx mcgpibConnect and scan
Section titled “Connect and scan”With mcgpib registered, start a Claude Code session and walk through the connection. Here is what a typical first conversation looks like.
-
Connect to the bridge
Ask Claude to connect, or call the tool directly:
> Connect to my GPIB bridge "bench-a"Claude calls
connect_bridge("bench-a"). The server opens the serial port (or TCP socket), sends initialization commands to disable verbose mode and the command prompt, then reads the firmware version. Ifauto_scanis enabled, it also discovers instruments on the bus.You should see a response like:
Connected to bench-a: AR488 GPIB controller 0.05.99Discovered 3 instrument(s):Address 1: HEWLETT-PACKARD 34401AAddress 5: KEITHLEY INSTRUMENTS INC. 2000Address 22: Agilent Technologies E3631A -
Scan the bus manually (optional)
If
auto_scanwas disabled in your config, or if you have added instruments since connecting, scan explicitly:> Scan the GPIB bus on bench-aClaude calls
bus_scan("bench-a", identify=True). The bridge sends++findlstnto poll every address from 1 to 30, then sends*IDN?to each listener to identify it.Bus scan on bench-a: 3 listener(s)Address 1: HEWLETT-PACKARD 34401A (S/N: 3146A02377)Address 5: KEITHLEY INSTRUMENTS INC. 2000 (S/N: 1234567)Address 22: Agilent Technologies E3631A (S/N: MY12345678) -
Verify a specific instrument
To get detailed identification for a single instrument:
> Identify the instrument at address 5 on bench-aClaude calls
instrument_identify("bench-a", 5):Address 5 on bench-a:Manufacturer: KEITHLEY INSTRUMENTS INC.Model: 2000Serial: 1234567Firmware: A04 /A02Raw: KEITHLEY INSTRUMENTS INC.,2000,1234567,A04 /A02
Your bridge is connected and your instruments are discovered. You are ready to start taking measurements.
What is next
Section titled “What is next”- First Measurement — send SCPI commands to a multimeter and read a DC voltage
- Multi-Bridge Setup — configure serial and TCP bridges for cross-bus workflows
- Configuration Reference — full documentation of every config field
- Tool Reference — complete list of all 22 tools with parameters and examples