Skip to content

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.


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 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

NameTypeRequiredDescription
backendstringYesName 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 2000

Disconnect from a backend. Closes all underlying transport connections. Instruments on the bus return to local control.

Parameters

NameTypeRequiredDescription
backendstringYesName of the backend to disconnect

Example

result = await client.call_tool("disconnect_backend", {
"backend": "bench-a"
})

Returns

Disconnected from bench-a

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

NameTypeRequiredDescription
backendstringYesName 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 2000

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

NameTypeRequiredDescription
instrumentstringYesVISA resource string or configured alias
commandstringYesCommand to send (typically ends with ?)

Example

# Query by alias
result = await client.call_tool("instrument_query", {
"instrument": "dmm",
"command": "MEAS:VOLT:DC?"
})
# Query by VISA resource string
result = await client.call_tool("instrument_query", {
"instrument": "GPIB0::22::INSTR",
"command": "MEAS:VOLT:DC?"
})
# Check operation complete
result = await client.call_tool("instrument_query", {
"instrument": "psu",
"command": "*OPC?"
})

Returns

The raw response string from the instrument, for example:

+4.23451000E+00

Send a command to an instrument with no response expected. Use this for configuration commands that set parameters without returning data.

Parameters

NameTypeRequiredDescription
instrumentstringYesVISA resource string or configured alias
commandstringYesCommand to send

Example

# Configure a Keithley 2000 for DC voltage measurement
await client.call_tool("instrument_write", {
"instrument": "dmm",
"command": "CONF:VOLT:DC 10,0.001"
})
# Turn on output on a power supply
await client.call_tool("instrument_write", {
"instrument": "psu",
"command": "OUTP ON"
})
# Using a VISA resource string directly
await client.call_tool("instrument_write", {
"instrument": "GPIB0::9::INSTR",
"command": "TRIG:SOUR IMM"
})

Returns

Sent to dmm: CONF:VOLT:DC 10,0.001

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

NameTypeRequiredDescription
instrumentstringYesVISA 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,A01

Send *RST to reset an instrument to its power-on defaults. This clears all configuration and returns the instrument to a known state.

Parameters

NameTypeRequiredDescription
instrumentstringYesVISA resource string or configured alias

Example

result = await client.call_tool("instrument_reset", {
"instrument": "dmm"
})

Returns

Reset instrument dmm (GPIB0::22::INSTR)