JM

jigarbhoye04/matlabmcp

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

19 stars 5 forks Качество 58 Тренд 0MIT

MCP-сервер для запуска MATLAB-кода от LLM через API Matlab Engine.

Обзор

Это реализация сервера Model Context Protocol (MCP) для MATLAB. Это позволяет MCP-клиентам (например, агентам LLM или Claude Desktop) взаимодействовать с общим сеансом MATLAB с помощью API MATLAB Engine для Python. Запустите произвольные фрагменты кода MATLAB через инструмент RunMatlabCode. * Получить значение переменных из рабочего пространства MATLAB с помощью инструмента getVariable. Инструменты возвращают результаты и ошибки в виде структурированного JSON для более простого программного использования клиентами. Звонки движка MATLAB выполняются асинхронно с использованием asyncio.to thread для предотвращения блокировки сервера. * Использует стандартный модуль регистрации Python, выводящий на stderr для видимости в журналах клиентов. * Подключается к существующей совместной сессии MATLAB. Википедия MatlabMCP от DEVIN. Проверьте DeepWiki для получения более подробной и иллюстративной информации об архитектуре. * Python 3.12 или выше * MATLAB (проверьте MATLAB Engine API для совместимости с Python) с установленным MATLAB Engine API для Python. Пакет Numpy Python. 2.

Обзор (машинный перевод)

Это реализация сервера Model Context Protocol (MCP) для MATLAB. Это позволяет MCP-клиентам (например, агентам LLM или Claude Desktop) взаимодействовать с общим сеансом MATLAB с помощью API MATLAB Engine для Python.

Особенности

** Исполните MATLAB-код: ** Запустите произвольные фрагменты кода MATLAB через инструмент runMatlabCode.

        • Переменные восстановления: * * Получите значение переменных из рабочего пространства MATLAB с помощью инструмента getVariable. ** Структурная коммуникация:** Инструменты возвращают результаты и ошибки в виде структурированного JSON для более простого программного использования клиентами. ** Неблокирующее исполнение: ** Звонки движка MATLAB выполняются асинхронно с использованием asyncio.to_thread для предотвращения блокировки сервера. ** Стандартная регистрация: ** Использует стандартный модуль Python logging, выводящий на stderr для видимости в журналах клиентов. ** Разделенная сессия: ** Подключается к существующей совместной сессии MATLAB.

[!TIP] Википедия MatlabMCP от DEVIN. Проверьте DeepWiki для получения более подробной и иллюстративной информации об архитектуре.

Требования

Python 3.12 или выше

  • MATLAB (R2023a или выше рекомендовано - проверить MATLAB Engine API на совместимость с Python) с установленным MATLAB Engine API на Python.

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

MATLAB MCP Integration

This is an implementation of a Model Context Protocol (MCP) server for MATLAB. It allows MCP clients (like LLM agents or Claude Desktop) to interact with a shared MATLAB session using the MATLAB Engine API for Python.

Features

  • Execute MATLAB Code: Run arbitrary MATLAB code snippets via the runMatlabCode tool.
  • Retrieve Variables: Get the value of variables from the MATLAB workspace using the getVariable tool.
  • Structured Communication: Tools return results and errors as structured JSON for easier programmatic use by clients.
  • Non-Blocking Execution: MATLAB engine calls are run asynchronously using asyncio.to_thread to prevent blocking the server.
  • Standard Logging: Uses Python’s standard logging module, outputting to stderr for visibility in client logs.
  • Shared Session: Connects to an existing shared MATLAB session.

[!TIP] MatlabMCP wikipedia by DEVIN. Checkout DeepWiki for more detailed and illustrative information about architecture.

Requirements

  • Python 3.12 or higher
  • MATLAB (R2023a or higher recommended - check MATLAB Engine API for Python compatibility) with the MATLAB Engine API for Python installed.
  • numpy Python package.

Installation

  1. Clone this repository:

    git clone https://github.com/jigarbhoye04/MatlabMCP.git
    cd MatlabMCP
    
  2. Set up a Python virtual environment (recommended):

    # Install uv if you haven't already: https://github.com/astral-sh/uv
    uv init
    uv venv
    source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
    
  3. Install dependencies:

    uv pip sync
    
  4. Ensure MATLAB is installed and the MATLAB Engine API for Python is configured for your Python environment. See MATLAB Documentation.

  5. Start MATLAB and share its engine: Run the following command in the MATLAB Command Window:

    matlab.engine.shareEngine
    

    You can verify it’s shared by running matlab.engine.isEngineShared in MATLAB (it should return true or 1). The MCP server needs this shared engine to connect.

Configuration (for Claude Desktop)

To use this server with Claude Desktop:

  1. Go to Claude Desktop -> Settings -> Developer -> Edit Config.

  2. This will open claude_desktop_config.json. Add or modify the mcpServers section to include the MatlabMCP configuration:

    {
      "mcpServers": {
        "MatlabMCP": {
          "command": "C:\\Users\\username\\.local\\bin\\uv.exe", // Path to your uv executable
          "args": [
            "--directory",
            "C:\\Users\\username\\Desktop\\MatlabMCP\\", // ABSOLUTE path to the cloned repository directory
            "run",
            "main.py"
          ]
Открыть полный README на GitHub

Установка

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

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "mcpServers": { "MatlabMCP": { "command": "C:\\Users\\username\\.local\\bin\\uv.exe", // Path to your uv executable "args": [ "--directory", "C:\\Users\\username\\Desktop\\MatlabMCP\\", // ABSOLUTE path to the cloned repository directory "run", "main.py" ] // Optional: Add environment variables if needed // "env": { // "MY_VAR": "value" // } } // Add other MCP servers here if you have them } }