Skip to content

Scan and Identify Instruments

After connecting to a backend, you need to discover what instruments are available. mcpyvisa provides discover_instruments for discovery and instrument_identify for detailed identification of individual devices.

discover_instruments finds all reachable instruments on a backend. For AR488 backends, this sends the ++findlstn command to poll GPIB addresses 1 through 30. For pyvisa-py and system backends, it queries the VISA resource manager.

> Discover instruments on bench-a

The LLM calls discover_instruments("bench-a"). With the default identify=True, it also sends *IDN? to each instrument found:

Instruments on bench-a: 3 found
GPIB0::1::INSTR -> HEWLETT-PACKARD 34401A (S/N: 3146A02377)
GPIB0::5::INSTR -> KEITHLEY INSTRUMENTS INC. 2000 (S/N: 1234567)
GPIB0::22::INSTR -> Agilent Technologies E3631A (S/N: MY12345678)

If you have configured aliases, they appear alongside the resource strings:

Instruments on bench-a: 3 found
GPIB0::1::INSTR (voltmeter) -> HEWLETT-PACKARD 34401A (S/N: 3146A02377)
GPIB0::5::INSTR (ammeter) -> KEITHLEY INSTRUMENTS INC. 2000 (S/N: 1234567)
GPIB0::22::INSTR (psu) -> Agilent Technologies E3631A (S/N: MY12345678)

If you only need to know which instruments are reachable, pass identify=False:

> Discover instruments on bench-a without sending *IDN?

The LLM calls discover_instruments("bench-a", identify=False):

Instruments on bench-a: 3 found
GPIB0::1::INSTR -> listener found
GPIB0::5::INSTR -> listener found
GPIB0::22::INSTR -> listener found

This is faster and avoids potential issues with instruments that do not handle *IDN? gracefully.

To get detailed identification for a single instrument:

> Identify the ammeter

The LLM calls instrument_identify("ammeter"):

ammeter (GPIB0::5::INSTR on bench-a):
Manufacturer: KEITHLEY INSTRUMENTS INC.
Model: 2000
Serial: 1234567
Firmware: A04 /A02
Raw: KEITHLEY INSTRUMENTS INC.,2000,1234567,A04 /A02

You can also use VISA resource strings directly:

instrument_identify("GPIB0::5::INSTR")

The *IDN? response follows the IEEE 488.2 format: four comma-separated fields for manufacturer, model, serial number, and firmware version. mcpyvisa parses these into structured fields.

Not all instruments return clean *IDN? strings. Here is what to expect:

Instrument era*IDN? behavior
Modern IEEE 488.2 (Keysight, R&S, Keithley)Clean four-field response
Older HP/Agilent (34401A, E3631A)Standard response but may vary in field formatting
Pre-488.2 instruments (HP 3478A, Fluke 8842A)No response — times out
Mixed-protocol instrumentsMay return partial or non-standard strings

To see an overview of all configured backends and discovered instruments:

> Show server status

The LLM calls server_status():

mcpyvisa server status:
Backends: 2 configured, 1 connected
bench-a (ar488/serial): connected, 3 instruments
lan-bench (pyvisa-py): disconnected
Known instruments:
dmm -> GPIB0::22::INSTR (bench-a) -> HEWLETT-PACKARD 34401A
ammeter -> GPIB0::5::INSTR (bench-a) -> KEITHLEY INSTRUMENTS INC. 2000
psu -> GPIB0::1::INSTR (bench-a) -> Agilent Technologies E3631A
scope -> TCPIP::192.168.1.100::INSTR (lan-bench) -> not connected

Handle instruments that do not support *IDN?

Section titled “Handle instruments that do not support *IDN?”

For pre-488.2 instruments, you need a different approach:

  1. Discover without identification to confirm the instrument is reachable:

    > Discover instruments on bench-a without identifying
  2. Try a known command for the instrument you expect at that address. For example, the HP 3478A uses F1RA to configure DC voltage autorange:

    > Send "F1RA" to GPIB0::22::INSTR and read the response

    The LLM calls instrument_query("GPIB0::22::INSTR", "F1RA").

  3. Check the instrument’s front panel for a response. Many older instruments display “REMOTE” or “RMT” when they receive a valid command over GPIB.

When you power cycle instruments or reconnect GPIB cables:

  1. Wait for instruments to boot. Many instruments take 5—30 seconds for self-test after power-on.

  2. Run a new discovery:

    > Discover instruments on bench-a again

    This replaces the previous discovery results entirely. Any instruments that are no longer on the bus will disappear from the list.

  3. If instruments are missing, check:

    • GPIB cable connections (the connectors are stackable — make sure they are seated firmly)
    • Power status on each instrument
    • GPIB address switches or menu settings have not changed

If auto_discover = true and auto_identify = true in the backend config, instrument discovery happens automatically when you call connect_backend. The results are immediately available through server_status without a separate discover_instruments call.

To skip automatic discovery (for faster connections or to avoid disturbing instruments), set auto_discover = false in the config and discover manually when ready.