Instrument MCP Server
Enables natural language control of test instruments like spectrum analyzers and power supplies via SCPI commands, with auto-discovery and multi-instrument session support.
README
Instrument MCP Server
A Model Context Protocol (MCP) server for controlling test instruments via SCPI commands.
Supports Keysight MXA/EXA spectrum analyzers, R&S CMW500 wireless testers, and Keysight DC power supplies.
Features
- Natural language instrument control - Control instruments through conversational AI
- Auto-discovery - Automatically identifies instrument models via *IDN?
- YAML-driven commands - Easy to add new instruments without code changes
- Multi-instrument sessions - Connect and control multiple instruments simultaneously
- Error handling - Automatic error queue reading and diagnostics
- AI self-learning - AI can explore, learn, and save new instrument commands
Prerequisites
Before installing, ensure you have:
- Python 3.10+
- VISA Backend (one of the following):
- NI-VISA (Windows/Linux)
- Keysight IO Libraries Suite (Windows)
- pyvisa-py (pure Python, limited support)
Note: Without a VISA backend, the package will install but cannot communicate with instruments.
Supported Instruments
| Instrument | Type | Connection |
|---|---|---|
| Keysight MXA N9020A / N9010A / EXA | Spectrum Analyzer | VISA (TCP/IP/GPIB/USB) |
| R&S CMW500 | Wireless Communication Tester | VISA (TCP/IP) |
| Keysight 66311B / 66311 | DC Power Supply | VISA (GPIB) |
| Generic SCPI instruments | Any | VISA |
Installation
Using uv (recommended)
# 从 PyPI 安装
uv tool install instrument-mcp
# 或从本地源码安装
uv tool install .
# 或开发模式安装
uv tool install --editable .
Using pip
pip install instrument-mcp
From source
git clone https://github.com/yourusername/instrument-mcp.git
cd instrument-mcp
pip install -e .
Usage
As a standalone MCP Server
# 启动服务器(stdio 模式,用于 MCP 客户端)
instrument-mcp
# 或使用 Python 模块
python -m instrument_mcp.server
# 使用 uv 运行(无需全局安装)
uv run instrument-mcp
Configure in Claude Desktop
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"instrument": {
"command": "instrument-mcp"
}
}
}
Or with uv (if not globally installed):
{
"mcpServers": {
"instrument": {
"command": "uv",
"args": ["run", "instrument-mcp"]
}
}
}
Or with full path:
{
"mcpServers": {
"instrument": {
"command": "python",
"args": ["-m", "instrument_mcp.server"]
}
}
}
Using with Claude Code
# Add to your project
claude mcp add instrument instrument-mcp
Example Commands
Once connected, you can use natural language:
"Connect to the MXA at 192.168.1.100"
"Set center frequency to 2.4 GHz with 100 MHz span"
"Run a peak search and read the marker"
"Configure harmonic measurement with 7 harmonics"
"Fetch the harmonic amplitude values"
Or with the CMW500:
"Connect to CMW500 at 172.22.1.3"
"Preset the instrument"
"Set LTE Band 7, 20MHz bandwidth"
"Turn on the cell"
"Check UE connection status"
Development
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check .
# Debug with MCP inspector
mcp dev src/instrument_mcp/server.py
Project Structure
instrument-mcp/
├── src/instrument_mcp/
│ ├── server.py # MCP Server entry point
│ ├── instruments.py # VISA communication layer
│ └── commands/
│ ├── __init__.py # YAML command loader
│ ├── mxa.yaml # MXA spectrum analyzer commands
│ ├── cmw.yaml # CMW500 commands
│ ├── keysight_ps.yaml # Power supply commands
│ └── generic.yaml # Generic SCPI commands
├── pyproject.toml
└── README.md
Adding New Instruments
- Create a new YAML file in
src/instrument_mcp/commands/ - Define
instrument_type,model_keywords, andcommands - Restart the server - commands are loaded automatically
Example YAML structure:
instrument_type: my_instrument
description: My Test Instrument
model_keywords:
- "MYMODEL"
- "MYBRAND"
commands:
- name: my_command
description: Does something useful
params:
- name: param1
type: string
description: A parameter
default: "default_value"
scpi_template:
query: "MY:CMD? {param1}"
Troubleshooting
"No module named 'pyvisa'" or VISA errors
Install a VISA backend:
# Option 1: NI-VISA (recommended for Windows)
# Download from https://www.ni.com/en-us/support/downloads/drivers/download.ni-visa.html
# Option 2: pyvisa-py (pure Python, limited support)
pip install pyvisa-py
Connection timeout
- Verify instrument is powered on and network reachable:
ping 192.168.1.100 - Check instrument is not locked by another software
- Verify VISA address format:
TCPIP::IP::INSTR,GPIB0::5::INSTR
Commands not found after saving
Restart the MCP Server to reload commands from .instrument_mcp/ directory.
Release Checklist (for maintainers)
Before publishing to PyPI:
- [ ] Update version in
pyproject.toml - [ ] Update
CHANGELOG.md - [ ] Run tests:
pytest - [ ] Run lint:
ruff check . - [ ] Build package:
python -m build - [ ] Test installation:
pip install dist/*.whl - [ ] Upload to PyPI:
twine upload dist/*
License
MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。