
Generic SCPI Instrument
io.github.K-Dense-AI由 GitHub 帳號 K-Dense-AI 發布v0.1.3更新於 Oct 27, 2026
Generic MCP server for any SCPI instrument over VISA, TCP or serial, with command allow/deny lists.
概覽
本機 MCP 伺服器,讓助理透過 VISA、TCP 或序列埠對幾乎任何 SCPI 儀器送出查詢與命令,並支援命令允許/拒絕清單。
- 可以做什麼
- 辨識儀器身分、列出本機可見的 VISA 資源,並回報連線資訊、唯讀狀態與生效的安全限制
- 送出單一唯讀 SCPI 查詢,讀取波形、截圖等 IEEE 488.2 二進位區塊,可存成檔案
- 送出 SCPI 程式訊息或短命令序列、重設儀器、等待待處理操作完成
- 透過裝置清除或重新連線恢復卡住的儀器,並套用已設定的安全狀態
- 讀取並清空儀器錯誤佇列,檢視原始命令與回覆紀錄
- 提供 SCPI 語法速查與目前的命令策略
- 適用情境
- 適合讓助理操作電表、示波器、電源供應器、源表、函數產生器等支援 SCPI 的桌上型儀器,尤其是沒有官方 MCP 伺服器的品牌。也適用於腳本化量測、波形擷取與排查儀器錯誤。
- 執行需求
- 以 Python 套件(uvx labmcp-scpi)在本機透過 stdio 執行,僅限桌機。需在 LABMCP_ADDRESS 或位址參數提供儀器位址,並具備可用介面:GPIB、USBTMC、區域網路 VXI-11/HiSLIP 或原始通訊埠、RS-232。依賴 PyVISA 與 VISA 後端,NI-VISA 為選用。內建模擬器(LABMCP_SIMULATE)可在沒有硬體時測試。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Generic SCPI Instrument,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Generic SCPI Instrument — MCP Server
Let an AI agent talk to any IEEE 488.2 / SCPI instrument: multimeters, oscilloscopes, source-measure units, power supplies, electronic loads, function generators, spectrum analyzers and counters. It works over GPIB, USBTMC, LAN (VXI-11, HiSLIP, raw socket) and RS-232. Because the agent writes raw SCPI, the server puts the safety in the plumbing. The read path accepts only single queries. Anything that changes the instrument goes through tools the MCP client asks you to confirm. You can give the server command allow and deny lists and a safe-state command of your own.
Keysight or Rohde & Schwarz instrument? Use the vendor's official MCP server instead: Keysight MCP Server for Instrument Control or the MCP server that ships with RsInstrument (
python -m RsInstrument.mcp).labmcp-scpicovers everything else: Tektronix/Keithley, Rigol, Siglent, SRS, Aim-TTi, B&K Precision, GW Instek, older HP/Agilent GPIB gear, and more.
Try it without hardware
The simulator is a small, generic bench instrument (*IDN? → LabMCP,SIM-DMM-PSU,SIM000001,1.0.0). It is a 0–30 V / 3 A supply driving a 100 Ω load, with a built-in DMM across the load. It supports MEASure:VOLTage:DC?, CONFigure + READ?/FETCh?, [SOURce:]VOLTage/CURRent, OUTPut[:STATe], TRIGger:COUNt, FORMat[:DATA] REAL,32|64 binary blocks, FORMat:BORDer, *ESR?/*STB?, and a 10-entry SYSTem:ERRor? queue (overflow gives -350). In --simulate mode, the safe state is OUTP OFF.
Connect your instrument
- Instrument setup: enable the remote interface you want to use.
- LAN: set a fixed IP address. Enable VXI-11/HiSLIP (for VISA) or the SCPI raw-socket server. Many instruments use port 5025 for the socket; check the LAN settings page or the manual.
- USB: select USBTMC / "USB device (TMC)", not "USB mass storage" or a virtual COM port.
- GPIB: note the instrument's GPIB address.
- RS-232: set the baud rate, parity and handshake, and select SCPI as the language if the instrument asks.
- Find it:
uvx labmcp ports, or ask the agent to runlist_visa_resources. That tool works without--addressand lists VISA resources through pyvisa-py; passbackend=@ivito use NI-VISA or another vendor VISA library. - Test the connection:
--checkprints the parsed*IDN?reply. If it times out, check the terminator: SCPI uses LF by default, and some serial instruments needread_termination=CRLF. Also check the baud rate, and that the instrument is set to SCPI rather than an emulation language.
Add to your MCP client
Claude Code
Claude Desktop / Cursor / Windsurf (claude_desktop_config.json, .cursor/mcp.json, …)
Add --read-only to allow only queries. In read-only mode scpi_write, scpi_batch and reset_instrument disappear. device_clear and apply_safe_state stay available. Run one server per instrument, each with its own key (scope, psu, dmm, …).
Tools
get_connection_info, get_command_log and reconnect are built into every LabMCP server. apply_safe_state is listed only when a safe state is configured.
Command policy
A generic server cannot know which SCPI commands are dangerous on your instrument. It enforces what it can and lets you add the rest:
Matching rules:
- Patterns are Python regular expressions, matched case-insensitively.
- Each
;-separated message unit is checked in two forms. The first is the unit as sent, upper-cased, with collapsed whitespace and no leading colon. The second reduces every mnemonic to its SCPI short form (SCPI-99 Vol. 1 §6.2.1)::OUTPut1:STATe ONbecomesOUTP1:STAT ON. So^OUTP\d*(:STAT)? (?!OFF\b)catchesOUTP ON,outp:stat 1,VOLT 5;:OUTPut:STATe ONandOUTPut2 ON. - SCPI booleans accept any number (it is rounded, and anything non-zero means ON), so
OUTP 2,OUTP 1.0andOUTP #H1also switch an output on. Deny "everything except OFF", as above, rather than listing(ON|1). - The denylist uses
re.search. It also resolves relative headers (OUTP:POL NORM;STAT ONis checked asOUTP:STAT ON) and splits at every;, even inside quotes. The allowlist must match a whole unit. - Every step of
scpi_batchis checked before the first step is sent.
Examples:
The environment variable LABMCP_OPTIONS splits on commas. For regular expressions that contain commas, pass them on the command line or give LABMCP_OPTIONS as a JSON object ({"write_denylist": "..."}).
Safety limits
Override at launch: --limit max_block_bytes=67108864. This server has no voltage or current limits because it cannot interpret arbitrary commands. Set limits on the instrument itself (OVP/OCP, compliance, output protection), use a denylist, or use an instrument-specific server.
Example prompts
- "What instrument is connected? Read its identity and check the error queue."
- "Configure the DMM for DC volts on the 10 V range, take 20 readings, and give me the mean and standard deviation."
- "Set the supply to 3.3 V with a 200 mA current limit, read both back, but don't enable the output yet."
- "Grab channel 1's waveform from the scope as a binary block, save it to ~/data/ch1.csv, and summarise min, max and mean."
- "We got a -222 error. What does it mean, and which of the last commands caused it?"
- "Something's wrong: apply the safe state, then clear the interface."
Notes
- A generic server cannot make an arbitrary instrument safe.
device_cleardoes four things: a VISA device clear (on raw socket and serial links it only discards unread input), reads the error queue, sendsABORt, and sends*CLS. It recovers communication and stops sweeps. It does not switch outputs off. Configuresafe_statefor anything that sources energy. For hazardous gear, use an instrument-specific LabMCP server where one exists: it can enforce real setpoint limits. - Queries are not always read-only. On source-measure units such as the Keithley 2400,
MEASure?,READ?,INITiateandCONFigurecan switch the source output on (Keithley 2400 Series SourceMeter User's Manual, 2400S-900-01 Rev. G, §11 and §17). In--read-onlymode,scpi_querytherefore refusesMEASure?andREAD?by default, whileFETCh?still returns the last reading. Set--option allow_measure_in_read_only=trueif the instrument is a meter that cannot source. When not read-only, add--option query_denylist=^(MEAS|READ)for SMUs so these commands need confirmation throughscpi_write. *RST: SCPI-99 Vol. 2 §15.12 requiresOUTPut:STATe OFFafter*RST. But*RSTalso resets levels, ranges, limits and trigger settings, and not every instrument complies.- The error queue is read (and so cleared) after every
scpi_write/scpi_batchstep. The errors appear in the result. A query the instrument doesn't recognise produces no reply: the server times out (5 s by default,--timeoutto change), resynchronises, and reports the-113from the queue. - Instruments that don't implement
SYSTem:ERRor?(some older IEEE 488.2-only gear) reporterror_check: "unavailable". Set--option error_query=…if your instrument uses a different error query. query_binary_blockreads definite-length blocks (#<n><len><data>) only. Indefinite#0blocks are refused. Byte order followsFORMat:BORDer(NORMal = big-endian).timeout_scovers the whole transfer. Decoded NaN and infinite values are returned asnull(and counted innon_finite); the saved CSV keeps them asnan/inf.save_pathmust end in.csv(decoded values withdecode_as, otherwise the raw bytes),.bin,.dat,.raw,.txtor an image extension (.png,.bmp,.jpg,.jpeg,.gif,.tif,.tiff).~is expanded and missing folders are created. An existing file is never replaced unless you passoverwrite=true, and the check happens before anything is sent to the instrument.scpi_batchstops starting new steps after about 14 minutes (its tool timeout is 15 minutes). Steps that were not sent are markednot_run.- Text is sent as ASCII. Commands with control or non-ASCII characters are refused, and the server adds the LF terminator.
- A denylist is a guard rail, not a guarantee. It matches text, so vendor-specific aliases or macros (
*DMC, user-defined sequences) can evade it. Keep the instrument's own protection limits set.
Hardware verification
來源:servers/protocols/scpi-instrument/README.md,提交 46545ea
工具
0版本歷史
2- v0.1.3最新Sep 27, 2026
- v0.1.1Sep 26, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分