pyvisa-mcp
Control and learn SCPI test instruments (oscilloscopes, etc.) over USB/LAN/GPIB via MCP.
Discover and open instruments (VISA, IP, socket)
Identify and learn instrument dialect, save/reuse profiles
Fetch and search programming manuals, remember SCPI commands
Send/query SCPI commands (including binary blocks)
Capture and export oscilloscope waveforms (scaled, downsampled or full)
Measure signal characteristics (Vpp, frequency, etc.)
Configure scope (V/div, timebase, trigger, coupling)
Run/stop/single/autoset acquisition
Grab screenshots
Manage learned instruments and read error queues
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pyvisa-mcp connect to my Rigol at 192.168.1.10 and measure Vpp on channel 1"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pyvisa-mcp
MCP server that puts PyVISA in front of AI tools so they can discover, learn, and drive oscilloscopes (and other SCPI instruments) over USB, GPIB, serial, and Ethernet.
This project is not affiliated with the PyVISA maintainers. It uses the public PyVISA API.
How learn works
SCPI has no “dump every menu” command. Instead the server builds a local brain per instrument (keyed by *IDN?) and reuses it next session.
Saved under ~/.local/share/pyvisa-mcp/ (override with PYVISA_MCP_MEMORY):
What is stored | Where it comes from |
Identity, dialect, class |
|
Options / HELP headers / setup dump |
|
Programming manual (PDF + extracted text) | Web search, or |
SCPI that already worked or failed on this firmware | Every |
open_instrument 192.168.1.10
learn_instrument deep=true fetch_manual=true
search_scope_knowledge query="FFT"
search_scope_knowledge query="I2C decode"
search_scope_knowledge query=":WAV:DATA?"Next chat, learn_instrument reloads that brain. Pass a PDF you already have:
learn_instrument manual_url="/path/to/DS1054Z_ProgrammingGuide.pdf"search_scope_knowledge searches the manual text, HELP headers, and remembered commands. That is how the model reuses what it learned instead of guessing vendor SCPI.
list_learned_instruments / forget_instrument manage the store. Resources: visa://learned, visa://learned/{key}.
Writes: fail closed
After *IDN? / learn_instrument:
Known scope (Rigol, Keysight, Tektronix, Siglent, LeCroy) — writes allowed.
Anything else (unknown brand, DMM, PSU, “generic” fallback) — queries and learn only. No scale/trigger/run/stop until:
unlock_writes confirm=trueThat permission is stored on the local brain for this *IDN?. instrument_capabilities shows the gate.
Related MCP server: pyMSO5000 MCP Server
Talk to a network oscilloscope
LAN scopes often do not appear in list_instruments. Open by IP (Utility → I/O → LAN on the scope):
open_instrument resource="192.168.1.10"that becomes TCPIP0::192.168.1.10::inst0::INSTR (VXI-11 / LXI).
If it times out, try raw SCPI (Keysight/Siglent often 5025, Rigol DS1000Z often 5555):
open_instrument resource="192.168.1.10:5025"Then measure / capture:
learn_instrument
scope_measure kinds=["vpp","freq"]
scope_capture_waveform channel=1
export_waveform path="/tmp/ch1.csv"Tools
Tool | Purpose |
| Local VISA resources (USB/GPIB/serial; LAN often missing) |
| mDNS browse for LXI / VXI-11 / HiSLIP / SCPI-raw |
| Open by VISA name or IP ( |
| Identify, save/reload the local brain; |
| Download or ingest a programming guide into that brain |
| Search the saved manual + enumerated SCPI + remembered commands |
| List or delete saved brains |
| Raw SCPI (successes/failures are remembered) |
| Drain |
| Scaled volts-vs-time, downsampled for MCP |
| Full trace to CSV / NPY / BIN (no downsample) |
| Vpp, frequency, RMS, … |
| V/div, s/div, coupling, edge trigger |
| run / stop / single / autoset ( |
| PNG/BMP/JPEG when the vendor returns a real image |
| Whether this box may receive writes |
| Allow writes on an unknown dialect ( |
| Map a known intent to SCPI; says “no mapping” instead of guessing |
Resources: visa://howto, visa://scpi, visa://resource-names, visa://oscilloscope/{vendor}, visa://learned, visa://learned/{key}, visa://open, visa://backend.
High-level scope_* tools refuse DMMs / spectrum analyzers / PSUs unless you pass dialect=. Unknown dialects also cannot write / configure / capture until unlock_writes.
Install
pip install -e ".[dev]"
# or
uv sync --extra devRuntime dependencies include pyvisa-py. You do not need NI-VISA or Keysight IO Libraries for LAN/SOCKET instruments.
USB-TMC without a vendor VISA: pip install pyvisa-mcp[usb] (needs libusb).
Run
stdio (what Grok, Claude Desktop, Cursor, etc. spawn):
pyvisa-mcp
# python -m pyvisa_mcpHTTP (optional):
pyvisa-mcp --transport streamable-http --port 8000
# endpoint: http://127.0.0.1:8000/mcpInspector:
uv run mcp dev src/pyvisa_mcp/server.pyConnect an AI host
Grok (~/.grok/config.toml)
[mcp_servers.pyvisa]
command = "uv"
args = ["run", "--directory", "/path/to/pyvisa-mcp", "pyvisa-mcp"]
env = { PYVISA_LIBRARY = "@py" }
startup_timeout_sec = 45
tool_timeout_sec = 90After install onto PATH:
[mcp_servers.pyvisa]
command = "pyvisa-mcp"
env = { PYVISA_LIBRARY = "@py" }Claude Desktop / Cursor (.mcp.json)
{
"mcpServers": {
"pyvisa": {
"command": "pyvisa-mcp",
"env": { "PYVISA_LIBRARY": "@py" }
}
}
}Environment
Variable | Meaning |
| VISA backend. |
| Default I/O timeout (ms). Default |
| Comma-separated globs of allowed resources, e.g. |
|
|
| Path to |
*RST and autoset need confirm=true.
Vendor dialects
learn_instrument maps *IDN? manufacturer + model class to a dialect (not a substring of HANTEK/INSTEK):
keysight (Agilent / HP InfiniiVision-style scopes)
tektronix (
CURV?,MEASU:IMM:*)rigol
siglent (
C1,C1:PAVA?)lecroy
generic — unknown vendors, and Keysight/Tek boxes that are not scopes (DMM, SA, PSU, AWG)
Firmware forks still happen. If a helper fails: search_scope_knowledge, then query / write, then read_errors.
scope_capture_waveform min/max-downsamples (default 400 points) so MCP payloads stay small. Use export_waveform for the full record.
Tests
uv run pytestTests use an in-memory fake oscilloscope (no hardware). Optional pyvisa-sim YAML lives in tests/sim/scope.yaml.
Safety
This process can change instrument state: timebase, trigger, acquisition, autoset, *RST. Point PYVISA_MCP_ALLOW at the instruments you mean to touch, use PYVISA_MCP_READONLY=1 when you only want to look, and do not expose the HTTP transport on an untrusted network.
Available Tools
22 toolsclose_instrumentClose instrument sessionA
Close one open instrument, or all of them if resource is omitted.
Inputs: resource. Returns: result
configure_sessionConfigure VISA sessionC
Change timeout and terminators on an already-open instrument.
Inputs: resource, baud_rate, timeout_ms, read_termination, +1 more. Returns: model, notes, serial, dialect, +7 more
discover_network_instrumentsDiscover instruments on the LANARead-only
Browse mDNS for LXI, VXI-11, HiSLIP, and SCPI-raw services.
Many scopes do not advertise. Empty result is normal — open by IP instead.
Inputs: timeout_s. Returns: result
export_waveformExport waveform to a fileARead-only
Fetch a channel trace and write the full record (no downsample) to disk.
CSV columns: t_s, v. Use this for archives; scope_capture_waveform is for a short preview in the chat.
Inputs: path (required), fmt, channel, dialect, +1 more. Returns: t, v, vpp, dt_s, +14 more
fetch_manualFetch programming manualC
Download this model's user/programming guide into the local brain and index it.
Inputs: url, resource. Returns: deep, model, notes, cached, +16 more
forget_instrumentForget a learned instrumentC
Delete a saved per-scope profile from disk.
Inputs: identity (required). Returns: result
identifyIdentify instrument (*IDN?)BRead-only
Query *IDN? and pick a vendor dialect (keysight, tektronix, rigol, ...).
Inputs: resource. Returns: model, notes, serial, dialect, +7 more
learn_instrumentLearn an instrumentBRead-only
Build (or reload) a local brain for this exact *IDN?.
Saved under ~/.local/share/pyvisa-mcp/ (or PYVISA_MCP_MEMORY). Next session, learn_instrument returns the same profile, remembered SCPI, and manual text without probing again. Pass deep=true / fetch_manual=true to refresh.
Inputs: deep, resource, manual_url, fetch_manual. Returns: deep, model, notes, cached, +16 more
list_instrumentsList VISA instrumentsARead-only
Discover local VISA resources (USB, GPIB, serial, some LAN).
Network oscilloscopes frequently do NOT appear. Open them by IP with open_instrument, or call discover_network_instruments.
Inputs: query. Returns: result
list_learned_instrumentsList learned instrumentsARead-only
Profiles saved from previous learn_instrument calls (this machine).
Inputs: no named parameters. Returns: result
open_instrumentOpen a VISA instrumentA
Open an instrument and optionally query *IDN?.
Bare IPs become TCPIP::::INSTR. host:port becomes a raw TCP SOCKET, which is what many LAN scopes want on port 5025 (Rigol DS1000Z: 5555).
Inputs: resource (required), identify, baud_rate, timeout_ms, +2 more. Returns: model, notes, serial, dialect, +7 more
queryQuery SCPIBRead-only
Send a SCPI query and return the ASCII response.
Inputs: command (required), confirm, resource. Returns: ok, notes, command, resource, +1 more
query_binaryQuery binary SCPI blockARead-only
Read an IEEE binary block. By default returns stats + a short preview.
Pass save_path= to keep the full record, or return_values=true for a capped array. For oscilloscope traces prefer scope_capture_waveform / export_waveform. Do not use query() for binary — the terminator byte can appear inside the payload.
Inputs: command (required), datatype, resource, save_path, +4 more. Returns: path, notes, values, command, +6 more
read_errorsRead instrument error queueARead-only
Pop SYST:ERR? until the queue is empty. Call this after any failed command.
Inputs: resource, max_errors. Returns: result
scope_acquireRun / stop / single / autosetA
Control acquisition: run, stop, single shot, or vendor autoset.
Autoset changes vertical/horizontal/trigger; pass confirm=true.
Inputs: action (required), confirm, dialect, resource. Returns: ok, notes, command, resource, +1 more
scope_capture_waveformCapture oscilloscope waveformBRead-only
Read a scaled voltage-vs-time trace from one channel.
Uses the vendor dialect from *IDN? (or dialect=). Returns downsampled points plus vmin/vmax/vmean/vpp so the payload fits in an MCP tool result.
Inputs: channel, dialect, resource, max_points. Returns: t, v, vpp, dt_s, +14 more
scope_configureConfigure oscilloscopeB
Set channel scale/offset/coupling, timebase, and/or edge trigger.
Only provided fields are sent. Units: volts, seconds.
Inputs: probe, channel, dialect, display, +9 more. Returns: ok, notes, command, resource, +1 more
scope_measureOscilloscope measurementsCRead-only
Ask the scope's measurement engine for Vpp, frequency, etc.
Inputs: kinds, channel, dialect, resource. Returns: notes, channel, dialect, resource, +1 more
scope_screenshotOscilloscope screenshotBRead-only
Grab the scope display as PNG/BMP/JPEG.
Disables the VISA termchar so 0x0A inside the image is not treated as EOF. Fails if the payload is not a real image (no silent 'png' of ASCII junk).
Inputs: path, dialect, resource, timeout_ms.
search_scope_knowledgeSearch local scope knowledgeARead-only
Search the saved manual, HELP headers, and SCPI that already worked on this box.
Call learn_instrument / fetch_manual first. This is how the model reuses what it learned instead of guessing vendor commands.
Inputs: query (required), limit, resource. Returns: result
suggest_scpiSuggest SCPI for an intentBRead-only
Map a natural-language intent to vendor-correct SCPI. Optionally execute it.
Uses *IDN? dialect unless you pass dialect=. Prefer this over inventing commands.
Inputs: intent (required), channel, dialect, execute, +1 more. Returns: result
writeWrite SCPIA
Send a SCPI command with no reply (settings, *RST, :RUN, ...).
Inputs: command (required), confirm, resource. Returns: ok, notes, command, resource, +1 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 22 tools
Tools have largely distinct purposes, with clear boundaries between generic VISA operations and oscilloscope-specific ones. Minor potential overlap exists between identify and learn_instrument, and between query and suggest_scpi (when executing), but descriptions clarify usage.
All tool names use consistent snake_case, with a clear 'scope_' prefix for oscilloscope-specific tools. This predictable pattern aids discoverability and grouping.
22 tools is on the heavy side for the stated domain, slightly exceeding the typical 3-15 range. While many tools earn their place, some could potentially be consolidated (e.g., identify and learn_instrument), making the set borderline.
The surface covers the full lifecycle of instrument control: discovery, connection, identification, learning, SCPI communication, error handling, configuration, and scope-specific operations like waveform capture, measurement, acquisition, and screenshot. No major gaps are apparent for the domain.
Maintenance
Related MCP Connectors
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
AI Agent Utility Layer for agent safety, web monitoring, crypto research and tool discovery.
Connect AI clients to biomedical data and tools.
Configure AI agents, give them knowledge and tools, and read back every generation they run.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to directly control NI oscilloscopes (e.g., PXIe-5160/5164/5110) through the Model Context Protocol, including waveform acquisition, measurement, and configuration.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to control Rigol MSO5000 oscilloscopes through VISA, including acquisition, channels, trigger, timebase, waveform generator, display, and front-panel controls, with risk-based permission gating for direct SCPI operations.6MIT
- AlicenseBqualityDmaintenanceEnables agentic coding harnesses to control benchtop test equipment — waveform generator, multimeter, oscilloscope, and power supply — over SCPI, with typed tools and raw passthrough for investigating circuits.761MIT
- FlicenseNot gradedqualityBmaintenanceEnables unified discovery, query, and control of laboratory instruments (power supplies, oscilloscopes, signal generators, multimeters) via VISA/SCPI, with device-specific libraries and an MCP server exposing 19 tools for natural language interaction.-