-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
- Python 3.10–3.12
- MATLAB R2022b+ installed locally
- MATLAB Engine API for Python — comes with MATLAB, needs separate install
The MATLAB Engine API lets Python call MATLAB. Install it from your MATLAB installation:
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .Adjust the path for your MATLAB version (e.g.,
R2023b,R2024b).
cd "C:\Program Files\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]"Note: The [dev] extras include all optional dependencies (testing, linting, monitoring). For a minimal install without dev/monitoring dependencies, use pip install -e . instead. To add only monitoring support (dashboard, health endpoint), use pip install -e ".[monitoring]".
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. Works on Windows 10/11 with Python 3.10, 3.11, or 3.12.
# Single user (stdio transport)
matlab-mcp
# Multi-user (SSE transport)
matlab-mcp --transport sse
# With custom config
matlab-mcp --config my_config.yamlAdd to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}claude mcp add matlab -- matlab-mcpAdd to .cursor/mcp.json in your project:
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}Start the server:
matlab-mcp --transport sseThen point your client to http://localhost:8765/sse.
docker build -t matlab-mcp .docker run -p 8765:8765 -p 8766:8766 \
-v /path/to/MATLAB:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcp --transport ssemacOS example:
docker run -p 8765:8765 -p 8766:8766 \
-v /Applications/MATLAB_R2024a.app:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcp --transport sseLinux example:
docker run -p 8765:8765 -p 8766:8766 \
-v /usr/local/MATLAB/R2024b:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcp --transport sseEdit docker-compose.yml to set your MATLAB path, then:
docker compose upThe docker-compose.yml includes service definitions with volumes for results and monitoring data:
volumes:
- ./config.yaml:/app/config.yaml:ro
- ./custom_tools.yaml:/app/custom_tools.yaml:ro
- /Applications/MATLAB_R2024a.app:/opt/matlab:ro # Adjust for your system
- results:/app/results
- monitoring_data:/app/monitoringNote: The Docker image does not include MATLAB. You must mount your own MATLAB installation and ensure the MATLAB Engine API for Python is accessible inside the container.
python -m venv .venv
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 server
cd /path/to/matlab-mcp-server-python
pip install -e ".[dev]"All settings live in config.yaml with sensible defaults. Override any setting via environment variables:
# Override pool size
export MATLAB_MCP_POOL_MIN_ENGINES=4
export MATLAB_MCP_POOL_MAX_ENGINES=16
# Override sync timeout (promote to async after 60s instead of 30s)
export MATLAB_MCP_EXECUTION_SYNC_TIMEOUT=60
# Override transport
export MATLAB_MCP_SERVER_TRANSPORT=sse
# Override MATLAB root directory (for Docker or non-standard installs)
export MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlabSee Configuration for all available options.
Ensure you've installed the MATLAB Engine API into the same Python environment as the server:
# Activate your venv first
source .venv/bin/activate
# Then install MATLAB Engine API
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .
# Verify
python -c "import matlab.engine; print('OK')"Verify the mount path is correct and MATLAB Engine API is installed in the container's Python. You can test inside the container:
docker run -it \
-v /Applications/MATLAB_R2024a.app:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcp bash
# Inside container:
python -c "import matlab.engine; print('OK')"If you previously installed as matlab-mcp-server, uninstall first:
pip uninstall matlab-mcp-server
pip install matlab-mcp-python