Universal Tools
These 8 tools work with any pyvisa backend — AR488, pyvisa-py, NI-VISA, or simulation. They cover backend lifecycle management, instrument discovery, and standard SCPI communication. A backend must be connected before instruments on it can be accessed.
Instruments are addressed by VISA resource string ("GPIB0::22::INSTR") or by a configured alias ("dmm"). Aliases are resolved through the [instruments] section of mcpyvisa.toml.
server_status
Section titled “server_status”Returns the current state of all configured backends (connected or not), discovered instruments, and the server version. This is the first tool to call when starting a session.
Parameters
This tool takes no parameters.
Example
result = await client.call_tool("server_status", {})Returns
mcpyvisa v0.1.0
Backends: bench-a: ar488 serial (/dev/ttyUSB0) [connected] lan: pyvisa-py [disconnected]
Instruments: GPIB0::5::INSTR — Agilent Technologies E3631A (alias: psu) GPIB0::22::INSTR — KEITHLEY INSTRUMENTS INC. MODEL 2000 (alias: dmm)connect_backend
Section titled “connect_backend”Connect to a backend and initialize it. For AR488 backends, this establishes serial or TCP communication and runs the AR488 initialization sequence. For pyvisa-py or system backends, this creates a pyvisa ResourceManager with the appropriate VISA library.
If auto_discover is enabled in the backend config, instruments are discovered immediately after connecting. If auto_identify is also enabled, *IDN? is sent to each discovered instrument.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
backend | string | Yes | Name of the backend to connect |
Example
result = await client.call_tool("connect_backend", { "backend": "bench-a"})Returns
Connected to bench-a (ar488 via /dev/ttyUSB0)Discovered 2 instrument(s): GPIB0::5::INSTR — Agilent Technologies E3631A GPIB0::22::INSTR — KEITHLEY INSTRUMENTS INC. MODEL 2000disconnect_backend
Section titled “disconnect_backend”Disconnect from a backend. Closes all underlying transport connections. Instruments on the bus return to local control.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
backend | string | Yes | Name of the backend to disconnect |
Example
result = await client.call_tool("disconnect_backend", { "backend": "bench-a"})Returns
Disconnected from bench-adiscover_instruments
Section titled “discover_instruments”Scan a backend for connected instruments. On GPIB backends, this sends ++findlstn to discover all listeners, then optionally sends *IDN? to each. On non-GPIB backends, this calls list_resources() to find connected instruments.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
backend | string | Yes | Name of the backend to scan |
Example
result = await client.call_tool("discover_instruments", { "backend": "bench-a"})Returns
Discovered 3 instrument(s) on bench-a: GPIB0::5::INSTR — Agilent Technologies E3631A GPIB0::7::INSTR — Tektronix TDS2024B GPIB0::22::INSTR — KEITHLEY INSTRUMENTS INC. MODEL 2000instrument_query
Section titled “instrument_query”Send a query to an instrument and return the response. This is the most common operation — send a command (typically ending with ?) and read back the instrument’s answer.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Yes | VISA resource string or configured alias |
command | string | Yes | Command to send (typically ends with ?) |
Example
# Query by aliasresult = await client.call_tool("instrument_query", { "instrument": "dmm", "command": "MEAS:VOLT:DC?"})
# Query by VISA resource stringresult = await client.call_tool("instrument_query", { "instrument": "GPIB0::22::INSTR", "command": "MEAS:VOLT:DC?"})
# Check operation completeresult = await client.call_tool("instrument_query", { "instrument": "psu", "command": "*OPC?"})Returns
The raw response string from the instrument, for example:
+4.23451000E+00instrument_write
Section titled “instrument_write”Send a command to an instrument with no response expected. Use this for configuration commands that set parameters without returning data.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Yes | VISA resource string or configured alias |
command | string | Yes | Command to send |
Example
# Configure a Keithley 2000 for DC voltage measurementawait client.call_tool("instrument_write", { "instrument": "dmm", "command": "CONF:VOLT:DC 10,0.001"})
# Turn on output on a power supplyawait client.call_tool("instrument_write", { "instrument": "psu", "command": "OUTP ON"})
# Using a VISA resource string directlyawait client.call_tool("instrument_write", { "instrument": "GPIB0::9::INSTR", "command": "TRIG:SOUR IMM"})Returns
Sent to dmm: CONF:VOLT:DC 10,0.001instrument_identify
Section titled “instrument_identify”Identify an instrument by sending the IEEE 488.2 *IDN? query. The response is parsed into four fields per the standard: manufacturer, model, serial number, and firmware version.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Yes | VISA resource string or configured alias |
Example
result = await client.call_tool("instrument_identify", { "instrument": "dmm"})Returns
dmm (GPIB0::22::INSTR): Manufacturer: KEITHLEY INSTRUMENTS INC. Model: MODEL 2000 Serial: 1234567 Firmware: A01 Raw: KEITHLEY INSTRUMENTS INC.,MODEL 2000,1234567,A01instrument_reset
Section titled “instrument_reset”Send *RST to reset an instrument to its power-on defaults. This clears all configuration and returns the instrument to a known state.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Yes | VISA resource string or configured alias |
Example
result = await client.call_tool("instrument_reset", { "instrument": "dmm"})Returns
Reset instrument dmm (GPIB0::22::INSTR)