Generic SCPI Instrument
v0.1.3Generic MCP server for any SCPI instrument over VISA, TCP or serial, with command allow/deny lists.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
get_connection_info Get Connection Info
Report which instrument is connected (identity, address, simulated or real), whether the server is read-only, and the active safety limits. Call this first.
get_command_log Get Command Log
Return the most recent raw commands sent to / replies received from the instrument (newest last). Useful for debugging and for recording what was done.
| Parameter | Type | Description |
|---|---|---|
limit | integer |
reconnect Reconnect
Close and re-open the connection to the instrument (e.g. after it was power cycled or a cable was re-plugged).
scpi_primer Scpi Primer
Concise SCPI syntax guide (long/short forms, queries, compound commands, common commands, error queue, binary blocks) plus this server's active command policy. Works without a connection.
identify Identify
Ask the instrument who it is (*IDN?): manufacturer, model, serial number, firmware.
list_visa_resources List Visa Resources
List GPIB / USBTMC / LAN (VXI-11, HiSLIP) instruments visible to VISA on this computer. Works without --address. Raw-socket instruments (tcp://host:5025) are not discoverable.
| Parameter | Type | Description |
|---|---|---|
backend | string | @py = pyvisa-py, @ivi = NI-VISA / Keysight / R&S VISA |
query | string | VISA resource filter |
scpi_query Scpi Query
Send ONE read-only SCPI query and return the instrument's text reply. Only single queries are accepted: the header must end with '?' (parameters such as 'VOLT? MAX' are allowed), with no ';' and no line breaks. Queries with known side effects (*TST?, *CAL?, CALibration, DIAGnostic) and anything in the lab's query denylist are refused - use `scpi_write` for those. An unknown query gets no reply (timeout); the error queue is then reported.
| Parameter | Type | Description |
|---|---|---|
command * | string | One SCPI query, e.g. '*IDN?', 'MEAS:VOLT:DC?', 'VOLT? MAX' |
max_chars | integer | Truncate longer replies |
timeout_s | Reply timeout (default: server's) |
query_binary_block Query Binary Block
Read an IEEE 488.2 definite-length binary block (waveforms, trace data, screenshots, FORMat REAL/INTeger readings). The query must pass the same read-only checks as `scpi_query`. Returns length, SHA-256 and (optionally) decoded values with summary statistics, downsampled to max_points; use save_path for the full data. Blocks larger than the `max_block_bytes` limit are discarded.
| Parameter | Type | Description |
|---|---|---|
command * | string | One SCPI query answering with #<n><len><data> |
byte_order | string | big = SCPI FORMat:BORDer NORMal, little = SWAPped |
decode_as | string | Interpret the payload as an array of this type (see the instrument's FORMat) |
max_inline_bytes | integer | Return the raw payload as base64 only up to this size |
max_points | integer | Max decoded values returned inline |
overwrite | boolean | Allow replacing an existing save_path |
save_path | Write the full data here: .csv with decode_as writes index,value rows; .bin/.dat/.raw/.txt/.png/.bmp/.jpg/.gif/.tif (or .csv with decode_as none) get the raw payload | |
timeout_s | number | Timeout for the whole transfer |
get_errors Get Errors
Read and clear the instrument's error/event queue (SYSTem:ERRor? until 0,"No error"). Entries are returned oldest first; each can only be read once. An empty list means no errors.
| Parameter | Type | Description |
|---|---|---|
max_errors | integer | Stop after this many entries |
wait_operation_complete Wait Operation Complete
Wait until the instrument has finished all pending operations (*OPC? returns 1), e.g. after starting a sweep, an acquisition or a settling source.
| Parameter | Type | Description |
|---|---|---|
timeout_s | number | Longest time to wait |
scpi_write Scpi Write
Send any SCPI program message (settings, compound 'A;B' messages, queries with side effects) and then read the error queue. If the message contains a query, its reply is returned. This can change the instrument's state, including switching outputs on; say what the command does before calling it. Commands in the lab's denylist, or outside its allowlist, are refused before anything is sent.
| Parameter | Type | Description |
|---|---|---|
command * | string | SCPI program message, e.g. 'VOLT 5;CURR 0.1' or 'OUTP ON' |
timeout_s | Reply timeout if it contains a query |
scpi_batch Scpi Batch
Run a short sequence of SCPI commands and queries in order, checking the error queue after every step. Every step is checked against the command policy BEFORE the first one is sent, so a refused step means nothing was sent. Returns per-step replies and errors. Steps not started within ~14 minutes are not sent (status not_run).
| Parameter | Type | Description |
|---|---|---|
steps * | array | Commands/queries to send in order |
delay_between_s | number | Pause between steps |
stop_on_error | boolean | Stop at the first step that reports an error |
timeout_s | Reply timeout per query |
reset_instrument Reset Instrument
Reset the instrument to its default settings (*RST, then *CLS), wait for completion and check errors. SCPI requires outputs OFF after *RST, but every other setting (levels, ranges, triggers, limits) returns to its default and some instruments differ: check the manual before resetting anything connected to a device under test.
| Parameter | Type | Description |
|---|---|---|
clear_status | boolean | Also send *CLS (clear status and error queue) |
device_clear Device Clear
Recover a stuck or confused instrument: VISA device clear (or discard unread input on socket/serial links), report the error queue, optionally ABORt, then *CLS. This does NOT make an arbitrary instrument safe (outputs stay as they are): use `apply_safe_state` if the lab configured one, or the instrument's own controls.
| Parameter | Type | Description |
|---|---|---|
send_abort | boolean | Also send ABORt (stop sweeps / measurements) |