Skip to content

Simulated Bench

This tutorial gets you from zero to a working mcpyvisa session using simulated instruments. No GPIB adapters, no physical test equipment, no proprietary VISA drivers. By the end, you will have queried a virtual multimeter, set a voltage on a virtual power supply, and seen exactly what a real session looks like — all backed by YAML definitions that respond like the real hardware.

  • Python 3.11+ with uv installed
  • Claude Code (or another MCP-compatible client)

That is it. No instruments, no adapters, no cables.

  1. Install with the sim extra

    The sim backend depends on pyvisa-sim, which is included in the sim optional dependency group:

    Terminal window
    uv add mcpyvisa[sim]
  2. Get the instrument definitions

    The GPIB Instrument Catalog provides all_instruments.yaml — a pyvisa-sim definition file containing 16 simulated instruments covering multimeters, power supplies, oscilloscopes, signal generators, and more.

    Clone the catalog (or just grab the YAML file):

    Terminal window
    git clone https://git.supported.systems/warehack.ing/mcgpib.git

    The file lives at mcgpib/gpib-catalog/sim/all_instruments.yaml.

  3. Create your configuration

    Create mcpyvisa.toml in your working directory (or at ~/.config/mcpyvisa/config.toml):

    mcpyvisa.toml
    [server]
    log_level = "INFO"
    [[backend]]
    name = "sim-bench"
    type = "sim"
    sim_file = "./gpib-catalog/sim/all_instruments.yaml"
    # Give a few instruments friendly names
    [instruments.dmm]
    resource = "GPIB0::22::INSTR"
    backend = "sim-bench"
    [instruments.psu]
    resource = "GPIB0::5::INSTR"
    backend = "sim-bench"
    [instruments.counter]
    resource = "GPIB0::3::INSTR"
    backend = "sim-bench"
  4. Add to Claude Code

    Terminal window
    claude mcp add mcpyvisa -- uvx mcpyvisa[sim]

Start a Claude Code session and try the following.

  1. Connect to the sim backend

    > Connect to my backend "sim-bench"

    Claude calls connect_backend("sim-bench"). The server creates a pyvisa ResourceManager pointing at your YAML definition file and discovers all 16 simulated instruments:

    Connected to sim-bench (sim)
    Discovered 16 instrument(s):
    GPIB0::1::INSTR — FLUKE,8842A
    GPIB0::2::INSTR — TEKTRONIX,TDS 2024B
    GPIB0::3::INSTR — HEWLETT-PACKARD,53131A (alias: counter)
    GPIB0::5::INSTR — HEWLETT-PACKARD,E3631A (alias: psu)
    GPIB0::7::INSTR — HEWLETT-PACKARD,1660A
    GPIB0::9::INSTR — HEWLETT-PACKARD,3488A
    GPIB0::10::INSTR — HEWLETT-PACKARD,33120A
    GPIB0::16::INSTR — KEITHLEY INSTRUMENTS INC.,MODEL 2000
    GPIB0::17::INSTR — HEWLETT-PACKARD,4284A
    GPIB0::18::INSTR — HEWLETT-PACKARD,8566B
    GPIB0::19::INSTR — HEWLETT-PACKARD,8657B
    GPIB0::22::INSTR — HEWLETT-PACKARD,34401A (alias: dmm)
    GPIB0::23::INSTR — HEWLETT-PACKARD,3458A
    GPIB0::24::INSTR — HEWLETT-PACKARD,3478A
    GPIB0::25::INSTR — KEITHLEY INSTRUMENTS INC.,MODEL 2400
    GPIB0::27::INSTR — KEITHLEY INSTRUMENTS INC.,MODEL 6517B

    These are classic bench instruments from HP/Agilent, Keithley, Fluke, and Tektronix. Each one responds to its documented SCPI (or legacy) command set.

  2. Identify an instrument by alias

    > Identify the instrument "dmm"
    dmm (GPIB0::22::INSTR on sim-bench):
    Manufacturer: HEWLETT-PACKARD
    Model: 34401A
    Serial: 0
    Firmware: 0
  3. Query the simulated multimeter

    > What is the DMM reading?

    Claude calls instrument_query("dmm", "MEAS:VOLT:DC?"). The simulated HP 34401A returns a randomized voltage reading:

    +1.23456789E+00

    Each query returns a different value — pyvisa-sim’s RANDOM() function generates plausible readings within the configured range.

  4. Set a voltage on the power supply

    > Set the PSU output to 5 volts on channel P6V

    Claude sends the appropriate SCPI commands:

    instrument_write("psu", "INST:SEL P6V") → Sent to psu
    instrument_write("psu", "VOLT 5.0") → Sent to psu
    instrument_write("psu", "OUTP ON") → Sent to psu

    The simulated E3631A accepts these commands just as the real hardware would. Query back to confirm:

    > Read the voltage setting back
    instrument_query("psu", "VOLT?") → 5.000000E+00
  5. Explore other instruments

    With 16 instruments on the bus, there is plenty to explore:

    > What instruments are on the bus? Identify the signal generator.
    > Read a frequency from the counter
    > What does the Keithley 2400 source-measure unit support?