VISA MCP Server
GitHub CopilotとVS CodeでVISA計測器を制御するためのMCPサーバーです。
概要
このサーバーは、実験室の計測器(電源、オシロスコープ、マルチメータなど)をGitHub Copilotから簡単に制御できるようにします。TCPIP、GPIB、USBなど様々な接続方式に対応しています。
必要なもの
- Python 3.11以上
- VISA ランタイム(NI-VISA、Keysight IO Librariesなど)
- VS Code with GitHub Copilot
セットアップ
1. リポジトリのクローンと仮想環境の作成
git clone https://github.com/Hizuki1030/visa-mcp.git
cd visa-mcp
# 仮想環境を作成
python -m venv .venv
# 仮想環境を有効化
# macOS/Linux:
source .venv/bin/activate
# Windows:
# .venv\\Scripts\\activate
# 依存関係をインストール
pip install -e .
2. 動作確認
# 仮想環境が有効化されていることを確認
python test_visa.py
3. VS Codeに登録
VS Codeの設定に以下を追加(仮想環境のPythonパスを指定):
{
"servers": {
"visa-mcp": {
"command": "/path/to/visa-mcp/.venv/bin/python",
"args": ["src/server.py"],
"cwd": "/path/to/visa-mcp",
"env": {
"PYVISA_LOG_LEVEL": "INFO"
}
}
}
}
注意: /path/to/visa-mcpの部分は実際のプロジェクトパスに置き換えてください。
## 使い方
GitHub Copilotで「電源の電圧を5Vに設定して」のように自然な日本語で指示すると、適切なVISAコマンドが生成されます。
### 基本的な使用例
```python
# 機器の識別情報を取得
await send_visa_command("10.10.0.2", "inst0", "*IDN?")
# 電圧を設定
await send_visa_command("10.10.0.2", "inst0", "VOLT 5.0")
# 電圧を測定
await send_visa_command("10.10.0.3", "inst0", "MEAS:VOLT?")
パラメータ
host: 機器のIPアドレスresource_id: VISA リソース名(通常は "inst0")command: SCPI/VISAコマンドprotocol: 接続方式("tcpip", "gpib", "usb"など)
よくある問題
VISA ランタイムが見つからない
Error: Could not locate a VISA implementation
→ NI-VISAやKeysight IO Librariesをインストールしてください
接続タイムアウト
VISA Error: VI_ERROR_TMO
→ IPアドレスと機器の電源を確認してください
詳細ログの有効化
export PYVISA_LOG_LEVEL=DEBUG
python src/server.py
Recommend MCP Servers 💡
server-cmd
An MCP server for executing command-line operations (CMD commands) on Windows and Linux, including SSH connections, designed for integration with MCP-compatible applications.
ffmpeg-mcp
Using ffmpeg command line to achieve an mcp server, can be very convenient, through the dialogue to achieve the local video search, tailoring, stitching, playback,clip, overlay, concat and other functions
@magicuidesign/mcp
Official Magic UI MCP server for integrating components and configuration management
Wallet Inspector
An MCP server that empowers AI agents to inspect any wallet’s balance and onchain activity across major EVM chains and Solana chain.
PRIMS
PRIMS is a lightweight, open-source Model Context Protocol (MCP) server that lets LLM agents safely execute arbitrary Python code in a secure, throw-away sandbox.
replicate-flux-mcp
MCP for Replicate Flux Model - A powerful tool for generating customized images and SVG assets that match specific coding vibes and aesthetic styles. Streamline your visual asset creation process with AI-powered design generation tailored for developers.