MATLAB

MCP server to run MATLAB code from LLM via the Matlab Engine API.
  • python

20

GitHub Stars

python

Language

4 months ago

First Indexed

3 weeks ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jigarbhoye04-matlabmcp": {
      "command": "C:\\Users\\username\\.local\\bin\\uv.exe",
      "args": [
        "--directory",
        "C:\\Users\\username\\Desktop\\MatlabMCP\\",
        "run",
        "main.py"
      ]
    }
  }
}

This MATLAB MCP Server enables clients to control a shared MATLAB session from any MCP-compatible client. It provides tools to execute MATLAB code and retrieve workspace variables, returning results in structured JSON for easy consumption by agents and applications. The server connects to a pre-shared MATLAB engine and runs calls asynchronously to keep interactions responsive.

How to use

You connect your MCP client to the MATLAB MCP Server and use the available tools to run MATLAB code and fetch variable values from the MATLAB workspace. The server executes commands asynchronously, so long-running code won’t block incoming requests. Use the client’s standard MCP workflow to call the MATLAB tools, handle returned JSON, and manage any errors gracefully.

How to install

Prerequisites you need before starting the server are Python 3.12 or higher, MATLAB (R2023a or higher recommended) with the MATLAB Engine API for Python installed, and the numpy Python package.

# 1) Clone the repository
git clone https://github.com/jigarbhoye04/MatlabMCP.git
cd MatlabMCP

# 2) Set up a Python virtual environment
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
# (Follow MATLAB documentation for your OS)

# 5) Start sharing the MATLAB engine from the MATLAB command window
# MATLAB command:
matlab.engine.shareEngine

# 6) Verify sharing in MATLAB
matlab.engine.isEngineShared

Configuration and usage notes

To use this server with Claude Desktop, you configure an MCP entry that runs the server locally via the Unity/uv tool. The following configuration example shows how to start the server from a local path."

{
  "mcpServers": {
    "MatlabMCP": {
      "command": "C:\\Users\\username\\.local\\bin\\uv.exe",
      "args": [
        "--directory",
        "C:\\Users\\username\\Desktop\\MatlabMCP\\",
        "run",
        "main.py"
      ]
    }
  }
}

Troubleshooting and tips

If you encounter connection issues, verify that MATLAB Engine sharing is active and that the Python environment used by the server can import the MATLAB Engine API. Check logs for errors related to engine connectivity, asynchronous execution, or workspace variable access. If the engine is not shared, run matlab.engine.shareEngine in MATLAB and confirm that matlab.engine.isEngineShared returns true (or 1).

Available tools

runMatlabCode

Executes arbitrary MATLAB code snippets via the runMatlabCode tool and returns execution results or errors in structured JSON.

getVariable

Retrieves the value of a specified variable from the MATLAB workspace using the getVariable tool, returning it in a structured JSON format.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
MATLAB MCP Server - jigarbhoye04/matlabmcp | VeilStrat