TM

tsuchijo/matlab-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

40 stars 4 forks 品質 56 トレンド 12

モデル コンテキスト プロトコル サーバーで、LLM が matlab スクリプトを書き、実行できるように

概要

このモデルコンテキストプロトコル (MCP) サーバは、MATLAB と連携し、Claude や MCP クライアントを通じて MATLAB スクリプトや関数を作成、実行できます。 - Python 3.11 (Python 3.13 および 3.12 は現在 MATLAB Engine ではサポートされていません) - MATLAB R2024a (または互換性のあるバージョン) - uv パッケージマネージャ 1. Python環境の作成と設定: 2。 MATLABエンジンをインストールします。 MATLABエンジンは、MATLAB PATH環境変数で指定されたMATLABインストールを使用して、サーバーが最初に実行したときに自動的にインストールされます。 - matlab server.py: メインの MCP サーバーの実装 - matlab scripts/: すべての MATLAB スクリプトと関数が保存されるディレクトリ(自動的に作成) - pyproject.toml: Python プロジェクト構成 - .python-version: uv 用の Python バージョンを指定します 1.

概要(AI 翻訳)

このモデルコンテキストプロトコル (MCP) サーバは、MATLAB と連携し、Claude や MCP クライアントを通じて MATLAB スクリプトや関数を作成、実行できます。

セットアップ要件

  • Python 3.11 (Python 3.13 および 3.12 は MATLAB Engine ではサポートされていません)
  • MATLAB R2024a(または互換性のあるバージョン)
  • uvパッケージマネージャ

インストール

  1. Python環境の作成と設定:

  2. MATLABエンジンのインストール MATLABエンジンは、サーバーが最初に実行したときに自動的にインストールされます。[MATLAB_PATH]]環境変数で指定されたMATLABインストールを使用します。

ディレクトリ構造

  • [matlab_server.py]: メインの MCP サーバーの実装
  • [matlab_scripts/: すべてのMATLABスクリプトと関数が保存されるディレクトリ(自動的に作成)
  • [pyproject.toml]: Python プロジェクト構成
  • [.python-version]: uv 用の Python バージョンを指定する

#Claudeデスクトップの統合

1。 Claudeデスクトップの設定を開きます。

  1. MATLAB サーバーの設定を追加します。

お問い合わせ

  • プロジェクトディレクトリの実際のパスで[/absolute/path/to/matlab-mcpを置換します
  • [MATLAB_PATHポイントをMATLABインストールを確認します
  • 絶対パスを使う(相対パスではなく)

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

MATLAB MCP Server

This Model Context Protocol (MCP) server provides integration with MATLAB, allowing you to create and execute MATLAB scripts and functions through Claude or other MCP clients.

Setup Requirements

  • Python 3.11 (Python 3.13 and 3.12 are not currently supported by MATLAB Engine)
  • MATLAB R2024a (or compatible version)
  • uv package manager

Installation

  1. Create and set up the Python environment:
# Pin Python version
uv python pin 3.11

# Create virtual environment
uv venv

# Activate virtual environment
source .venv/bin/activate

# Install MCP
uv add "mcp[cli]"
  1. Install MATLAB Engine The MATLAB Engine will be installed automatically when the server first runs, using the MATLAB installation specified in the MATLAB_PATH environment variable.

Directory Structure

  • matlab_server.py: The main MCP server implementation
  • matlab_scripts/: Directory where all MATLAB scripts and functions are saved (created automatically)
  • pyproject.toml: Python project configuration
  • .python-version: Specifies Python version for uv

Claude Desktop Integration

  1. Open your Claude Desktop configuration:
# On macOS
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. Add the MATLAB server configuration:
{
    "mcpServers": {
        "matlab": {
            "command": "uv",
            "args": [
                "--directory",
                "/absolute/path/to/matlab-mcp",
                "run",
                "matlab_server.py"
            ],
            "env": {
                "MATLAB_PATH": "/Applications/MATLAB_R2024a.app"
            }
        }
    }
}

Make sure to:

  • Replace /absolute/path/to/matlab-mcp with the actual path to your project directory
  • Verify the MATLAB_PATH points to your MATLAB installation
  • Use absolute paths (not relative)

Features

The server provides several tools:

  1. create_matlab_script: Create a new MATLAB script file

    • Scripts are saved in the matlab_scripts directory
    • File names must be valid MATLAB identifiers
  2. create_matlab_function: Create a new MATLAB function file

    • Functions are saved in the matlab_scripts directory
    • Must include valid function definition
  3. execute_matlab_script: Run a MATLAB script and get results

    • Returns output text, generated figures, and workspace variables
    • Can pass arguments to scripts
  4. call_matlab_function: Call a MATLAB function with arguments

    • Returns function output and any generated figures

Testing

You can test the server using the MCP Inspector:

# Make sure you're in your virtual environment
source .venv/bin/activate

# Run the inspector
MATLAB_PATH=/Applications/MATLAB_R2024a.app mcp dev matlab_server.py

Example test script:

t = 0:0.01:2*pi;
y = sin(t);
plot(t, y);
title('Test Plot');
xlabel('Time');
ylabel('Amplitude');

Script Storage

GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "matlab": { "command": "uv", "args": [ "--directory", "/absolute/path/to/matlab-mcp", "run", "matlab_server.py" ], "env": { "MATLAB_PATH": "/Applications/MATLAB_R2024a.app" } } } }