- Explore MCP Servers
- MatlabMCP
Matlabmcp
What is Matlabmcp
This is a Model Context Protocol (MCP) server implemented in MATLAB that facilitates real-time interactions between MCP clients and a MATLAB session. It utilizes the MATLAB Engine API for Python to enable clients to execute MATLAB code and retrieve workspace variables seamlessly.
Use cases
The MCP server allows users to run MATLAB scripts, fetch variable values from the workspace, and manage MATLAB sessions from external applications. This is particularly useful for integration with AI tools or applications that require access to MATLAB’s computational capabilities.
How to use
Users must clone the repository, set up a Python virtual environment, install dependencies, and ensure that the MATLAB Engine API for Python is configured. After sharing the MATLAB engine via the command window, users can configure Claude Desktop to connect with the MCP server by editing the appropriate configuration JSON file.
Key features
The MCP server supports executing MATLAB code, retrieving variables, and structured JSON communication for client-server interaction. It runs task executions asynchronously, utilizes standard logging for monitoring, and connects to a shared MATLAB session, providing a flexible environment for MATLAB collaborations.
Where to use
This MCP server can be utilized in environments where MATLAB’s capabilities are needed alongside other software tools, such as AI applications, automation scripts, or any system that benefits from MATLAB’s data processing and computational features.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Matlabmcp
This is a Model Context Protocol (MCP) server implemented in MATLAB that facilitates real-time interactions between MCP clients and a MATLAB session. It utilizes the MATLAB Engine API for Python to enable clients to execute MATLAB code and retrieve workspace variables seamlessly.
Use cases
The MCP server allows users to run MATLAB scripts, fetch variable values from the workspace, and manage MATLAB sessions from external applications. This is particularly useful for integration with AI tools or applications that require access to MATLAB’s computational capabilities.
How to use
Users must clone the repository, set up a Python virtual environment, install dependencies, and ensure that the MATLAB Engine API for Python is configured. After sharing the MATLAB engine via the command window, users can configure Claude Desktop to connect with the MCP server by editing the appropriate configuration JSON file.
Key features
The MCP server supports executing MATLAB code, retrieving variables, and structured JSON communication for client-server interaction. It runs task executions asynchronously, utilizes standard logging for monitoring, and connects to a shared MATLAB session, providing a flexible environment for MATLAB collaborations.
Where to use
This MCP server can be utilized in environments where MATLAB’s capabilities are needed alongside other software tools, such as AI applications, automation scripts, or any system that benefits from MATLAB’s data processing and computational features.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
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
runMatlabCodetool. - Retrieve Variables: Get the value of variables from the MATLAB workspace using the
getVariabletool. - 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_threadto prevent blocking the server. - Standard Logging: Uses Python’s standard
loggingmodule, outputting tostderrfor visibility in client logs. - Shared Session: Connects to an existing shared MATLAB session.
TODO:
- Add a
setVariabletool to write data to the MATLAB workspace. - Add a
runScripttool to execute.mfiles directly. - Add tools for workspace management (e.g.,
clearWorkspace,getWorkspaceVariables). - Expand
matlab_to_pythonhelper 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.
numpyPython 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.shareEngineYou can verify it’s shared by running
matlab.engine.isEngineSharedin MATLAB (it should returntrueor1). 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 themcpServerssection to include theMatlabMCPconfiguration: -
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
loggingmodule) will appear in Claude Desktop’s MCP log files (accessible viatail -f ~/Library/Logs/Claude/mcp-server-MatlabMCP.logon 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!
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










