-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
- Python 3.10+ (3.12 recommended for best performance)
- MATLAB R2022b+ installed locally
- MATLAB Engine API for Python — included with MATLAB, requires separate installation
| Platform | MATLAB Versions | Notes |
|---|---|---|
| macOS | R2022b–R2024b | Max 4 concurrent engines recommended (known stability limits) |
| Windows | R2022b–R2024b | Tested on Windows 10/11 with Python 3.10, 3.11, 3.12 |
| Linux | R2022b–R2024b | Requires MATLAB license server or local installation |
The MATLAB Engine API must be installed into your Python environment first.
macOS:
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .Windows (Command Prompt):
cd "C:\Program Files\MATLAB\R2024a\extern\engines\python"
pip install .Linux:
cd /path/to/matlab/R2024a/extern/engines/python
pip install .Adjust the path for your MATLAB version (e.g.,
R2023b,R2024a).
Verify the installation:
import matlab.engine
eng = matlab.engine.start_matlab()
result = eng.eval("2 + 2", nargout=1)
print(result) # Should print 4.0
eng.quit()pip install matlab-mcp-pythonWith optional dependencies:
# Install with monitoring dashboard and metrics
pip install "matlab-mcp-python[monitoring]"
# Install with development tools (testing, linting)
pip install "matlab-mcp-python[dev]"
# Install with everything
pip install "matlab-mcp-python[dev,monitoring]"matlab-mcp --versionExpected output: matlab-mcp-server version 1.4.1
git clone https://github.com/HanSur94/matlab-mcp-server-python.git
cd matlab-mcp-server-python# Minimal install (no monitoring or dev tools)
pip install -e .
# With monitoring dashboard
pip install -e ".[monitoring]"
# With dev dependencies (pytest, ruff, etc.)
pip install -e ".[dev]"
# All extras
pip install -e ".[dev,monitoring]"# Run tests to verify everything works
pytest
# Check linting
ruff check src/
# Start the server
matlab-mcpA standalone Windows installer (install.bat) is provided for environments without pip or Python installed.
- Windows 10/11
- MATLAB R2022b+ installed and in system PATH
- Administrator access not required
-
Download
install.batfrom the repository -
Run the installer:
install.bat
-
Follow the prompts:
- The script auto-detects Python 3.10+ or prompts you to install it
- Auto-detects MATLAB installation or asks for the MATLAB root directory
- Creates a virtual environment in
matlab-mcp-env/ - Installs all dependencies from bundled wheels (fully offline)
-
Activate the virtual environment:
matlab-mcp-env\Scripts\activate
-
Verify installation:
matlab-mcp --version
"Python 3.10+ not found":
- Install Python from python.org
- Ensure you check "Add Python to PATH" during installation
"MATLAB not found":
- Ensure MATLAB is in your system PATH:
matlab -version - Or manually specify the MATLAB root when prompted
Wheels download fails:
- The installer has a fallback to pip: if wheels are unavailable, it will use pip instead
- Ensure you have internet access or use the offline wheels bundle
-
Edit
docker-compose.ymlto mount your MATLAB installation:volumes: - /path/to/MATLAB:/opt/matlab:ro
-
Build and run:
docker compose up
-
Verify:
curl http://localhost:8765/health curl http://localhost:8766/health # Dashboard
-
Build the image:
docker build -t matlab-mcp . -
Run the container:
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
Important: The Docker image does not include MATLAB. You must mount your local MATLAB installation. The image only includes Python and the MCP server code.
version: '3.8'
services:
matlab-mcp:
build:
context: .
dockerfile: Dockerfile
ports:
- "8765:8765" # MCP/SSE transport
- "8766:8766" # Dashboard
volumes:
- ./config.yaml:/app/config.yaml
- /path/to/MATLAB:/opt/matlab:ro
- ./results:/app/results
- ./monitoring:/app/monitoring
environment:
MATLAB_MCP_POOL_MATLAB_ROOT: /opt/matlab
MATLAB_MCP_SERVER_TRANSPORT: sse
MATLAB_MCP_POOL_MIN_ENGINES: 2
MATLAB_MCP_POOL_MAX_ENGINES: 8# Create virtual environment
python3.10 -m venv .venv
# Activate (macOS/Linux)
source .venv/bin/activate
# Activate (Windows)
.venv\Scripts\activate
# Install MATLAB Engine API
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .
# Install the MCP server
cd /path/to/matlab-mcp-server-python
pip install -e ".[dev,monitoring]"
# Verify
pytest
matlab-mcp --helpMinimal config (stdio mode, single user):
matlab-mcp # Uses defaultsMulti-user config (SSE mode):
matlab-mcp --transport sse --config config_multiuser.yamlFull config with all options:
matlab-mcp --config config.yaml --log-level debugSee Configuration Guide for all settings.
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}Then restart Claude.
Add to .cursor/mcp.json:
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}claude mcp add matlab -- matlab-mcpStart the server with SSE transport:
matlab-mcp --transport sseConfigure your client to connect to: http://localhost:8765/sse
import sys
print(f"Python {sys.version}")
import matlab.engine
print("MATLAB Engine API installed ✓")
eng = matlab.engine.start_matlab()
print(f"MATLAB version: {eng.version(nargout=1)}")
eng.quit()# Start server (stdio mode)
matlab-mcp &
SERVER_PID=$!
# Give it a moment to start
sleep 2
# Kill server
kill $SERVER_PIDpytest -v --cov=src/matlab_mcp tests/Expected: All tests pass with >90% coverage.
# Terminal 1: Start server in SSE mode
matlab-mcp --transport sse &
# Terminal 2: Check health endpoint
curl http://localhost:8765/health
# Check metrics
curl http://localhost:8766/metrics
# Open dashboard
open http://localhost:8766/dashboardExpected response (health endpoint):
{
"status": "healthy",
"uptime_seconds": 12.34,
"engines": {"total": 2, "available": 2, "busy": 0},
"jobs": {"active": 0, "completed": 0, "failed": 0},
"sessions": {"active": 1}
}graph TB
Client["AI Agent<br/>(Claude, Cursor, etc.)"]
Transport["Transport Layer<br/>(stdio / SSE)"]
Server["MCP Server<br/>(FastMCP)"]
Pool["Engine Pool Manager<br/>(2-10 engines)"]
Executor["Job Executor<br/>(sync/async)"]
Engine["MATLAB Engines<br/>(matlab.engine)"]
Monitor["Monitoring<br/>(metrics, dashboard)"]
Client -->|MCP Messages| Transport
Transport --> Server
Server --> Pool
Server --> Executor
Pool --> Engine
Executor --> Engine
Server --> Monitor
Pool -.->|Pool Status| Monitor
Executor -.->|Job Events| Monitor
Monitor -->|HTTP| Client
style Client fill:#e1f5ff
style Server fill:#fff3e0
style Pool fill:#f3e5f5
style Engine fill:#e8f5e9
style Monitor fill:#fce4ec
# Verify MATLAB is installed
matlab -version
# Re-install Engine API
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install --force-reinstall .
# Check installation
python -c "import matlab.engine; print('✓ MATLAB Engine API OK')"The MATLAB Engine API must be installed with the same Python version that will run the MCP server.
# Check your Python version
python --version
# Check MATLAB Engine API compatibility
python -c "import matlab.engine; import sys; print(f'Python {sys.version_info.major}.{sys.version_info.minor}')"- Ensure MATLAB Engine API is installed in your active Python environment
- If using a virtual environment, re-install the Engine API into that venv
- Check
pip list | grep matlab
On macOS, you may need to use python3 explicitly:
python3 --version # Should be 3.10+
cd /Applications/MATLAB_R2024a.app/extern/engines/python
python3 -m pip install .Add MATLAB to your system PATH:
- Open Environment Variables (Windows key + "environment")
- Add:
C:\Program Files\MATLAB\R2024a\binto PATH - Restart Command Prompt
Verify:
matlab -versionIf engines take >120 seconds to start:
- Check MATLAB startup time:
matlab -r "quit"(should complete in <30s) - Increase timeout in config:
pool: engine_start_timeout: 180 # 3 minutes
Ensure your MATLAB installation is mounted:
# Verify MATLAB is accessible inside container
docker run -v /path/to/MATLAB:/opt/matlab:ro matlab-mcp \
bash -c "ls -la /opt/matlab/bin/matlab"- Read the Configuration Guide to customize settings
- Check Examples for common MATLAB tasks
- Review Security for production deployments
- See MCP Tools Reference for available tools
sequenceDiagram
participant User
participant Installer
participant Python
participant MatlabEngine
participant Pool
participant Dashboard
User->>Installer: Run install command
Installer->>Python: Check version >= 3.10
Python-->>Installer: OK (3.10+)
Installer->>MatlabEngine: Verify installed
MatlabEngine-->>Installer: OK
Installer->>Pool: Create EnginePoolManager
Pool->>MatlabEngine: Start min_engines (e.g., 2)
MatlabEngine-->>Pool: Engines ready
Installer->>Dashboard: Initialize (if enabled)
Dashboard-->>Installer: Ready on :8766
Installer-->>User: ✓ Server running on :8765
User->>Python: Connect client
Python->>Pool: Acquire engine
Pool-->>Python: Engine allocated
Python->>MatlabEngine: Execute code
MatlabEngine-->>Python: Result
Python-->>User: Return to agent