
Matlabmcp
MCP Server zum Ausführen von MATLAB -Code von LLM über die Matlab Engine -API.
1
Github Watches
0
Github Forks
5
Github Stars
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 tostderr
for visibility in client logs. - Shared Session: Connects to an existing shared MATLAB session.
TODO:
- Add a
setVariable
tool to write data to the MATLAB workspace. - Add a
runScript
tool to execute.m
files directly. - Add tools for workspace management (e.g.,
clearWorkspace
,getWorkspaceVariables
). - Expand
matlab_to_python
helper to handle more complex data types (structs, cell arrays, objects). - Add support for interacting with Simulink models.
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
-
Clone this repository:
git clone https://github.com/jigarbhoye04/MatlabMCP.git cd MatlabMCP
-
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
-
Install dependencies:
uv pip sync
-
Ensure MATLAB is installed and the MATLAB Engine API for Python is configured for your Python environment. See MATLAB Documentation.
-
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 returntrue
or1
). The MCP server needs this shared engine to connect.
Configuration (for Claude Desktop)
To use this server with Claude Desktop:
-
Go to Claude Desktop -> Settings -> Developer -> Edit Config.
-
This will open
claude_desktop_config.json
. Add or modify themcpServers
section to include theMatlabMCP
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" ] // Optional: Add environment variables if needed // "env": { // "MY_VAR": "value" // } } // Add other MCP servers here if you have them } }
-
IMPORTANT: Replace
C:\\Users\\username\\...
paths with the correct absolute paths for your system. -
Save the file and restart Claude Desktop.
-
Logging: Server logs (from Python's
logging
module) will appear in Claude Desktop's MCP log files (accessible viatail -f ~/Library/Logs/Claude/mcp-server-MatlabMCP.log
on macOS or checking%APPDATA%\Claude\logs\
on Windows).
Development
Project Structure:
MatlabMCP/
├── .venv/ # Virtual environment created by uv
├── Docs/
│ └── Images/
│ └── Updates.md # Documentation for updates and changes
├── main.py # The MCP server script
├── pyproject.toml # Project metadata and dependencies
├── README.md # This file
└── uv.lock # Lock file for dependencies
Documentation
Check out Updates for detailed documentation on the server's features, usage, and development notes.
Contributing
Contributions are welcome! If you have any suggestions or improvements, feel free to open an issue or submit a pull request.
Let's make this even better together!
相关推荐
I find academic articles and books for research and literature reviews.
Confidential guide on numerology and astrology, based of GG33 Public information
Converts Figma frames into front-end code for various mobile frameworks.
Advanced software engineer GPT that excels through nailing the basics.
Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.
Take an adjectivised noun, and create images making it progressively more adjective!
Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.
Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.
Die All-in-One-Desktop & Docker-AI-Anwendung mit integriertem Lappen, AI-Agenten, No-Code-Agent Builder, MCP-Kompatibilität und vielem mehr.
Ein leistungsstarkes Neovim -Plugin für die Verwaltung von MCP -Servern (Modellkontextprotokoll)
MCP -Server für den Fetch -Webseiteninhalt mit dem Headless -Browser von Dramatikern.
Brücke zwischen Ollama und MCP -Servern und ermöglicht es lokalen LLMs, Modellkontextprotokoll -Tools zu verwenden
Fair-Code-Workflow-Automatisierungsplattform mit nativen KI-Funktionen. Kombinieren Sie visuelles Gebäude mit benutzerdefiniertem Code, SelbstHost oder Cloud, 400+ Integrationen.
🧑🚀 全世界最好的 llm 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Zusammenfassung der weltbesten LLM -Ressourcen.
Reviews

user_D2qgp3eB
MatlabMCP is an exceptional application for anyone working with MATLAB. It offers comprehensive tools and resources that streamline the coding process and improve efficiency. The intuitive interface and robust features make it a valuable addition to any programmer's toolkit. Highly recommended for both beginners and experienced users looking to enhance their MATLAB experience!