MATLAB MCP サーバー
このモデル コンテキスト プロトコル (MCP) サーバーは MATLAB との統合を提供し、Claude またはその他の MCP クライアントを通じて MATLAB スクリプトと関数を作成および実行できるようにします。
セットアップ要件
Python 3.11 (Python 3.13 および 3.12 は現在 MATLAB エンジンではサポートされていません)
MATLAB R2024a(または互換バージョン)
UVパッケージマネージャー
インストール
Python 環境を作成して設定します。
MATLAB エンジンをインストールします。MATLAB エンジンは、
MATLAB_PATH環境変数で指定された MATLAB インストールを使用して、サーバーの初回実行時に自動的にインストールされます。
ディレクトリ構造
matlab_server.py: メインのMCPサーバーの実装matlab_scripts/: すべてのMATLABスクリプトと関数が保存されるディレクトリ(自動的に作成されます)pyproject.toml: Python プロジェクト構成.python-version: uvのPythonバージョンを指定します
クロードデスクトップ統合
Claude デスクトップ構成を開きます。
MATLAB サーバー構成を追加します。
必ず次の点に注意してください:
/absolute/path/to/matlab-mcpプロジェクトディレクトリへの実際のパスに置き換えます。MATLAB_PATHがMATLABインストールを指していることを確認します絶対パスを使用する(相対パスではない)
特徴
サーバーはいくつかのツールを提供します:
create_matlab_script: 新しいMATLABスクリプトファイルを作成するスクリプトは
matlab_scriptsディレクトリに保存されますファイル名は有効なMATLAB識別子である必要があります
create_matlab_function: 新しいMATLAB関数ファイルを作成する関数は
matlab_scriptsディレクトリに保存されます有効な関数定義を含める必要があります
execute_matlab_script: MATLAB スクリプトを実行して結果を取得する出力テキスト、生成された図、ワークスペース変数を返します
スクリプトに引数を渡すことができる
call_matlab_function: 引数を指定してMATLAB関数を呼び出す関数の出力と生成された数値を返します
テスト
MCP Inspector を使用してサーバーをテストできます。
テスト スクリプトの例:
スクリプトストレージ
すべてのMATLABスクリプトと関数は
matlab_scriptsディレクトリに保存されます。このディレクトリはサーバーの起動時に自動的に作成されます
ファイル名は
<script_name>.mまたは<function_name>.mディレクトリは
matlab_server.pyと同じ場所にあります
環境変数
MATLAB_PATH: MATLABインストールへのパスデフォルト:
/Applications/MATLAB_R2024a.appClaudeデスクトップの設定で設定するか、直接実行するときに設定
トラブルシューティング
MATLABエンジンのインストールに失敗する
MATLAB_PATHが正しいことを確認する
エンジンを手動でインストールしてみます:
cd $MATLAB_PATH/extern/engines/python python setup.py install
Pythonバージョンの問題
Python 3.11を使用していることを確認してください
確認:
python --version必要に応じて
uv python pin 3.11使用してください
スクリプト実行エラー
matlab_scriptsディレクトリが存在することを確認するスクリプトの構文が有効であることを確認する
MATLAB出力でエラーメッセージを探す
アップデートとメンテナンス
MATLABのインストールを最新の状態に保つ
必要に応じてPythonパッケージを更新します:
uv pip install --upgrade mcp[cli]Python をアップデートする際に MATLAB エンジンの互換性を確認する
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.
Claude またはその他の MCP クライアントを通じてスクリプトと関数を作成および実行することにより、MATLAB との対話を可能にし、環境構成機能によるスクリプトの管理と実行結果の取得をサポートします。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityAllows Claude desktop app to execute terminal commands and edit files on your computer through MCP, with features including command execution, process management, and diff-based file editing.Last updated -2123,2604,878MIT License
Fused MCP Agentsofficial
-security-license-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- Asecurity-licenseAqualityA utility tool that enables Claude Desktop to interact with external tools via the Model Context Protocol, providing features like email sending and simple calculations while simplifying the MCP setup process.Last updated -2913MIT License
- -security-license-qualityAllows execution of MATLAB code from Python using the MATLAB Engine API, enabling a shared MATLAB session across multiple requests for seamless integration with Claude Desktop.Last updated -20MIT License