MATLAB MCP統合
これはMATLAB用のモデルコンテキストプロトコル(MCP)サーバーの実装です。MCPクライアント(LLMエージェントやClaude Desktopなど)は、Python用のMATLABエンジンAPIを使用して共有MATLABセッションと対話できます。
特徴
- MATLAB コードの実行:
runMatlabCode
ツールを使用して任意の MATLAB コード スニペットを実行します。 - 変数の取得:
getVariable
ツールを使用して、MATLAB ワークスペースから変数の値を取得します。 - **構造化された通信:**ツールは結果とエラーを構造化された JSON として返すため、クライアントによるプログラムでの使用が容易になります。
- 非ブロッキング実行: MATLAB エンジン呼び出しは、サーバーのブロックを防ぐために
asyncio.to_thread
を使用して非同期的に実行されます。 - 標準ログ: Python の標準
logging
モジュールを使用して、クライアント ログでの表示のためにstderr
に出力します。 - **共有セッション:**既存の共有 MATLAB セッションに接続します。
やるべきこと:
- MATLAB ワークスペースにデータを書き込むための
setVariable
ツールを追加します。 .m
ファイルを直接実行するためのrunScript
ツールを追加します。- ワークスペース管理用のツールを追加します (例:
clearWorkspace
、getWorkspaceVariables
)。 - より複雑なデータ型 (構造体、セル配列、オブジェクト) を処理できるように
matlab_to_python
ヘルパーを拡張します。 - Simulink モデルとの対話のサポートを追加します。
要件
- Python 3.12以上
- MATLAB ( R2023a 以上を推奨- Python との互換性については MATLAB Engine API を確認してください) と Python 用 MATLAB Engine API がインストールされています。
numpy
Python パッケージ。
インストール
- このリポジトリをクローンします:
- Python 仮想環境をセットアップします (推奨):
- 依存関係をインストールします:
- MATLABがインストールされ、Python環境向けにMATLABエンジンAPIが設定されていることを確認してください。MATLAB ドキュメントをご覧ください。
- MATLAB を起動してエンジンを共有します。MATLABコマンド ウィンドウで次のコマンドを実行します。MATLABで
matlab.engine.isEngineShared
を実行すると、共有エンジンであるかどうかを確認できます(true
または1
返されるはずです)。MCPサーバーへの接続には、この共有エンジンが必要です。
構成(Claude Desktop 用)
このサーバーをClaude Desktopで使用するには:
- Claude Desktop -> 設定 -> 開発者 -> 構成の編集に移動します。
claude_desktop_config.json``mcpServers
開きます。mcpServers セクションを追加または変更し、MatlabMCP
設定を含めます。- 重要:
C:\\Users\\username\\...
パスをシステムの正しい絶対パスに置き換えてください。 - ファイルを保存し、 Claude Desktop を再起動します。
- **ログ記録:**サーバー ログ (Python の
logging
モジュールから) は、Claude Desktop の MCP ログ ファイルに表示されます (macOS ではtail -f ~/Library/Logs/Claude/mcp-server-MatlabMCP.log
でアクセスでき、Windows では%APPDATA%\Claude\logs\
でアクセスできます)。
発達
プロジェクト構造:
ドキュメント
サーバーの機能、使用方法、開発ノートに関する詳細なドキュメントについては、 「アップデート」を参照してください。
貢献
貢献を歓迎します!ご提案や改善点がありましたら、お気軽に問題を報告したり、プルリクエストを送信してください。
一緒にさらに良くしていきましょう!
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
MATLAB エンジン API を使用して Python から MATLAB コードを実行できるようにし、複数のリクエスト間で共有 MATLAB セッションを有効にして、Claude Desktop とのシームレスな統合を実現します。
Related MCP Servers
- -securityFlicense-qualityAllows interaction with MATLAB by creating and executing scripts and functions through Claude or other MCP clients, supporting script management and execution result retrieval with environment configuration capabilities.Last updated -19Python
- AsecurityAlicenseAqualityFacilitates running Python code in a sandbox and generating images using the FLUX model via an MCP server compatible with clients like Goose and the Claude Desktop App.Last updated -221PythonMIT License
- AsecurityAlicenseAqualityIntegrates MATLAB with AI to execute code, generate scripts from natural language, and access MATLAB documentation seamlessly.Last updated -233JavaScriptApache 2.0
Fused MCP Agentsofficial
-securityAlicense-qualityA Python-based MCP server that allows Claude and other LLMs to execute arbitrary Python code directly through your desktop Claude app, enabling data scientists to connect LLMs to APIs and executable code.Last updated -26MIT License