-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
- Python 3.10, 3.11, or 3.12
- MATLAB R2022b+ with the MATLAB Engine API for Python installed
- MATLAB Engine API for Python — comes with MATLAB, needs separate installation into your Python environment
The MATLAB Engine API lets Python call MATLAB. Install it from your MATLAB installation directory:
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .Adjust the path for your MATLAB version (e.g.,
R2022b,R2023b,R2024b).
cd "C:\Program Files\MATLAB\R2024a\extern\engines\python"
pip install .cd /usr/local/MATLAB/R2024a/extern/engines/python
pip install .import matlab.engine
eng = matlab.engine.start_matlab()
result = eng.eval("2 + 2", nargout=1)
print(result) # Should print 4
eng.quit()pip install matlab-mcp-pythongit clone https://github.com/HanSur94/matlab-mcp-server-python.git
cd matlab-mcp-server-python
pip install -e ".[dev]"Installation variants:
-
Minimal install (no dev/monitoring):
pip install -e . -
With dev/testing tools:
pip install -e ".[dev]"(includespytest,pytest-asyncio,pytest-cov,ruff, etc.) -
With monitoring only:
pip install -e ".[monitoring]"(adds health endpoint and server metrics)
For Windows 10/11 with Python 3.10+:
git clone https://github.com/HanSur94/matlab-mcp-server-python.git
cd matlab-mcp-server-python
install.batThe installer auto-detects MATLAB, creates a virtual environment, and installs everything from bundled wheels — fully offline, no internet required.
matlab-mcpUse this for local development or connecting a single AI client.
matlab-mcp --transport sseThis starts an HTTP server on http://localhost:8765 with SSE endpoint at /sse. Multiple clients can connect simultaneously with session isolation.
matlab-mcp --config my_config.yaml
matlab-mcp --transport sse --config /path/to/config.yamlAdd to your Claude Desktop config:
-
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json -
Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}claude mcp add matlab -- matlab-mcpAdd to .cursor/mcp.json in your project:
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}docker build -t matlab-mcp .# Single-user (stdio) — for testing
docker run -p 8765:8765 -p 8766:8766 \
-v /path/to/MATLAB:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcpPlatform-specific MATLAB paths:
-
Linux:
-v /usr/local/MATLAB/R2024b:/opt/matlab:ro -
macOS:
-v /Applications/MATLAB_R2024b.app:/opt/matlab:ro - Windows: (use WSL2 or mount via Docker Desktop settings)
Create/edit docker-compose.yml:
services:
matlab-mcp:
build: .
ports:
- "8765:8765"
- "8766:8766"
volumes:
- ./config.yaml:/app/config.yaml:ro
- ./custom_tools.yaml:/app/custom_tools.yaml:ro
# Mount your MATLAB installation (uncomment and adjust for your OS):
# - /usr/local/MATLAB/R2024b:/opt/matlab:ro # Linux
# - /Applications/MATLAB_R2024b.app:/opt/matlab:ro # macOS
- results:/app/results
- monitoring_data:/app/monitoring
environment:
- MATLAB_MCP_SERVER_TRANSPORT=sse
- MATLAB_MCP_POOL_MAX_ENGINES=4
# - MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab # Uncomment when mounting MATLAB
volumes:
results:
monitoring_data:Then run:
docker compose upNote: The Docker image does not include MATLAB. You must mount your own MATLAB installation and set
MATLAB_MCP_POOL_MATLAB_ROOTenvironment variable to point to it inside the container.
For development or isolation:
# Create virtual environment
python -m venv .venv
# Activate it
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
# Install MATLAB Engine API into the venv
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .
# Install the server from source
cd /path/to/matlab-mcp-server-python
pip install -e ".[dev]"Override configuration settings without editing config.yaml:
# Pool configuration
export MATLAB_MCP_POOL_MIN_ENGINES=2
export MATLAB_MCP_POOL_MAX_ENGINES=10
export MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab
# Execution settings
export MATLAB_MCP_EXECUTION_SYNC_TIMEOUT=30
# Server settings
export MATLAB_MCP_SERVER_TRANSPORT=sse
export MATLAB_MCP_SERVER_HOST=0.0.0.0
export MATLAB_MCP_SERVER_PORT=8765
export MATLAB_MCP_SERVER_LOG_LEVEL=infoVerify the MATLAB Engine API is installed:
python -c "import matlab.engine; print('OK')"If this fails, reinstall from your MATLAB installation directory (see Step 1).
The default SSE port is 8765. Change it:
export MATLAB_MCP_SERVER_PORT=9000
matlab-mcp --transport sseEnsure the MATLAB path is correct and mounted read-only:
docker run -v /Applications/MATLAB_R2024b.app:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcpIf you previously installed as matlab-mcp-server:
pip uninstall matlab-mcp-server
pip install matlab-mcp-pythonThe new package name is matlab-mcp-python, and the command remains matlab-mcp.