Rigol DL3021 MCP服务器
用于通过以太网控制Rigol DL3021电子负载的模型上下文协议(MCP)服务器。使AI代理能够通过VISA TCP/IP上的SCPI命令执行自动负载测试工作流。
特性
- 仅限以太网 通过PyVISA TCP/IP进行通信
- 网络自动发现 未配置IP时
- 22个MCP工具 涵盖测量、输入控制、模式配置和设备管理
可用工具
| 类别 | 工具 |
|---|---|
| 连接 | ping, discover_devices, test_connection, connect, disconnect |
| 设备 | get_device_info, reset_device |
| 测量 | measure_voltage, measure_current, measure_power, measure_resistance, measure_all |
| 输入控制 | enable_input, disable_input, get_input_state |
| 模式 | set_mode, query_mode |
| CC模式 | set_cc_current, set_cc_slew_rate, cc_mode |
| CP模式 | set_cp_power, set_cp_current_limit, cp_mode |
安装
首先,安装包及其依赖项:
pip install -e .或与 uv:
uv pip install -e .这将安装以下依赖项:
pyvisa >= 1.11.0-VISA仪器通信pyvisa-py-纯Python VISA后端fastmcp >= 2.10.6-MCP服务器框架
配置
服务器使用环境变量进行配置:
| 变量 | 描述 | 默认值 |
|---|---|---|
RIGOL_DL3021_IP | 设备IP地址(可选,如果未设置,则自动发现) | 无 |
RIGOL_DL3021_PORT | SCPI端口 | 5555 |
克劳德代码
安装软件包后,将以下内容添加到您的 ~/.claude.json 文件下 mcpServers 按键:
{
"mcpServers": {
"rigol-dl3021": {
"type": "stdio",
"command": "uv",
"args": [
"run",
"--with", "fastmcp",
"--with", "pyvisa",
"--with", "pyvisa-py",
"fastmcp", "run",
"/path/to/rigol_dl3021_mcp_server/mcp_rigol_dl3021.py"
],
"env": {
"RIGOL_DL3021_PORT": "5555"
}
}
}
}替换 /path/to/rigol_dl3021_mcp_server/ 以及此存储库的实际路径。
光标
安装软件包后,将以下内容添加到 ~/.cursor/mcp.json (全球)或 .cursor/mcp.json (项目层面):
{
"mcpServers": {
"rigol-dl3021": {
"command": "uv",
"args": [
"run",
"--with", "fastmcp",
"--with", "pyvisa",
"--with", "pyvisa-py",
"fastmcp", "run",
"/path/to/rigol_dl3021_mcp_server/mcp_rigol_dl3021.py"
],
"env": {
"RIGOL_DL3021_PORT": "5555"
}
}
}
}替换 /path/to/rigol_dl3021_mcp_server/ 以及此存储库的实际路径。
用法
直接运行
python mcp_rigol_dl3021.py使用FastMCP
fastmcp run mcp_rigol_dl3021.py安装包
rigol-dl3021-mcp网络发现
要在网络上查找DL3021,请执行以下操作:
python rigol_dl3021/find_dl3021.py要测试特定IP:
python rigol_dl3021/test_ip.py 192.168.1.100项目结构
rigol_dl3021_mcp_server/
├── mcp_rigol_dl3021.py # MCP server (22 tools)
├── pyproject.toml # Package configuration
└── rigol_dl3021/
├── comm_base.py # Ethernet-only VISA communication
├── dl3021.py # DL3021 SCPI driver
├── find_dl3021.py # Network auto-discovery
└── test_ip.py # Single IP connectivity test许可证
麻省理工学院
