-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
- Python 3.10+
- MATLAB R2022b+ with the MATLAB Engine API for Python
graph TD
A["Choose Installation Method"] --> B["PyPI<br/>pip install"]
A --> C["Source<br/>git clone + pip install -e"]
A --> D["Docker<br/>docker compose"]
A --> E["Windows One-Click<br/>install.bat<br/>no admin required"]
B --> F["Latest stable release"]
C --> G["Development version<br/>optional dev extras"]
D --> H["Containerized deployment<br/>mounted MATLAB"]
E --> I["Bundled wheels<br/>offline install"]
F --> J["Ready to run<br/>matlab-mcp"]
G --> J
H --> J
I --> J
The MATLAB Engine API is required and comes with your MATLAB installation. Follow the steps below for your platform.
# Find your MATLAB installation (adjust version as needed)
cd /Applications/MATLAB_R2024a.app/extern/engines/python
# Install into your Python environment
pip install .Tip: Replace
R2024awith your MATLAB version (e.g.,R2023b,R2022b).
# Open Command Prompt and navigate to the Python Engine directory
cd "C:\Program Files\MATLAB\R2024a\extern\engines\python"
# Install
pip install .Tip: Replace
R2024awith your MATLAB version.
# Adjust path to your MATLAB installation
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()If you see 4, the MATLAB Engine API is correctly installed. If you get an import error, check your MATLAB installation path and ensure Python can access it.
Choose one of the following methods:
pip install matlab-mcp-pythonThis installs the latest stable release from PyPI.
# Clone the repository
git clone https://github.com/HanSur94/matlab-mcp-server-python.git
cd matlab-mcp-server-python
# Install in editable mode with dev extras
pip install -e ".[dev]"Optional extras:
-
.[dev]— includes pytest, ruff, coverage (full development environment) -
.[monitoring]— includes Plotly, monitoring dashboard only (no dev tools) -
.— minimal install (core only)
# Build the image
docker build -t matlab-mcp .
# Run with mounted MATLAB installation
docker run -p 8765:8765 -p 8766:8766 \
-v /path/to/MATLAB:/opt/matlab:ro \
-e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
matlab-mcpOr use the provided docker-compose.yml:
# Edit docker-compose.yml to set your MATLAB path
docker compose upNote: Docker images do not include MATLAB. You must mount your own MATLAB R2022b+ installation.
For Windows 10 users without administrator privileges:
git clone https://github.com/HanSur94/matlab-mcp-server-python.git
cd matlab-mcp-server-python
install.batThe script:
- Auto-detects Python 3.10, 3.11, or 3.12
- Auto-detects MATLAB R2022b+ installation
- Creates an isolated virtual environment
- Installs all dependencies from bundled wheels (fully offline)
- Works without admin rights
See docs/windows-deployment.md for detailed Windows setup guidance.
Homebrew (macOS):
brew tap HanSur94/matlab-mcp
brew install matlab-mcp-pythonConda/Mamba:
conda install -c HanSur94 matlab-mcp-python# Test the CLI
matlab-mcp --help
# Generate a bearer token (if using HTTP transports)
matlab-mcp --generate-token
# Quick test: run in inspect mode without MATLAB
matlab-mcp --inspectThe server reads from config.yaml (optional). If no config exists, defaults are used.
Create a minimal config:
server:
transport: stdio # or "sse" for multi-user, "streamablehttp" for agents
host: 127.0.0.1
port: 8765
pool:
min_engines: 2
max_engines: 10Override any setting via environment variables:
MATLAB_MCP_SERVER_TRANSPORT=sse matlab-mcp
MATLAB_MCP_POOL_MAX_ENGINES=20 matlab-mcpFor complete configuration reference, see wiki/Configuration.md.
-
Open your Claude Desktop config:
-
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json -
Windows:
%APPDATA%\Claude\claude_desktop_config.json
-
macOS:
-
Add the server entry:
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}- Restart Claude Desktop. The MATLAB tools should appear in the Tools panel.
# If matlab-mcp is in your PATH
claude mcp add matlab -- matlab-mcp
# Or specify the full path
claude mcp add matlab -- /path/to/matlab-mcpThen use the MATLAB tools in Claude Code's chat interface.
Add to .cursor/mcp.json in your project root:
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp"
}
}
}Restart Cursor and the MATLAB tools will be available.
Start the server with streamable HTTP transport:
# Generate a token
export MATLAB_MCP_AUTH_TOKEN=$(matlab-mcp --generate-token | grep "Token:" | awk '{print $NF}')
# Start the server
matlab-mcp --transport streamablehttpConnect Codex CLI:
codex-cli connect http://127.0.0.1:8765/mcp \
--auth-header "Authorization: Bearer $MATLAB_MCP_AUTH_TOKEN"For more agent connection examples, see docs/agent-onboarding.md.
Isolate dependencies in a virtual environment:
# Create environment
python -m venv .venv
# Activate
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
# Install MATLAB Engine API into venv
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .
# Install server
cd /path/to/matlab-mcp-server-python
pip install -e ".[dev]"ImportError: No module named 'matlab.engine'
Solution:
- Confirm MATLAB is installed:
which matlaborwhere matlab(Windows) - Verify Engine API installation path exists
- Try installing again:
cd /Applications/MATLAB_R2024a.app/extern/engines/python && pip install .
Solution:
- If using a virtual environment, ensure it's activated
- If installing from source, use
pip install -e .(with the.) - Check that the installation succeeded:
pip show matlab-mcp-python
Solution:
# Use a different port
matlab-mcp --host 127.0.0.1 --port 8766Or set in config.yaml:
server:
host: 127.0.0.1
port: 8766Solution:
- Check the server is running:
matlab-mcp --transport sse - Verify the port is accessible:
curl http://127.0.0.1:8765/health - On Windows, check Windows Firewall hasn't blocked the port (use
0.0.0.0binding or add firewall exemption)
Solution:
- On Windows with network drives, try disabling network path caching:
And set in
matlab-mcp --config config.yaml
config.yaml:pool: matlab_root: "C:\\Program Files\\MATLAB\\R2024a"
Solution:
The default binding is 127.0.0.1 (loopback), which doesn't require admin. If you need remote access:
- Run as admin once to add firewall rule
- Or ask your IT department to add an exemption for port 8765
- See
docs/windows-deployment.mdfor full guidance
- Read
wiki/Configuration.mdfor detailed config options - See
wiki/Examples.mdfor usage examples - Check
wiki/MCP-Tools-Reference.mdfor all available tools - View
docs/agent-onboarding.mdfor agent-specific connection guides
For issues or questions, open a GitHub issue or check the FAQ.