-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
MATLAB 2020b and later. The MATLAB Engine API for Python must be installed separately from your MATLAB installation.
No. The server requires a local MATLAB installation with the Engine API. It connects to real MATLAB engines, not a simulator.
Not currently. The server connects to locally-installed MATLAB via the Engine API, which requires a local installation.
Any agent that supports the Model Context Protocol (MCP): Claude Desktop, Claude Code, Cursor, GitHub Copilot (with MCP support), and custom agents built with MCP SDKs.
Yes:
pip install matlab-mcp-pythonYou still need to install the MATLAB Engine API separately from your MATLAB installation. See the Quick Start section in the README.
Yes. The project includes a Dockerfile and docker-compose.yml. The Docker image does not include MATLAB — you must mount your own MATLAB installation as a volume:
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 docker-compose (edit docker-compose.yml to set your MATLAB path):
docker compose upcd /Applications/MATLAB_R2024a.app/extern/engines/python # macOS
pip install .On Windows:
cd "C:\Program Files\MATLAB\R2024a\extern\engines\python"
pip install .Adjust the path for your MATLAB version and OS.
- stdio: Single user, simple setup. The AI agent launches the server process directly. Best for personal use.
- SSE: Multiple users, shared server. Users connect over HTTP with session isolation. Requires reverse proxy authentication for production.
# Single user (stdio)
matlab-mcp
# Multi-user (SSE)
matlab-mcp --transport sseYes, with SSE transport. Start the server on a remote machine and connect via HTTP. Always put it behind a reverse proxy with authentication for production use. Set require_proxy_auth: true in your config and bind to 127.0.0.1 if the proxy is on the same machine.
Code that finishes within sync_timeout (30s default) returns immediately. Longer code is automatically promoted to an async job — the agent gets a job_id and can poll for progress using get_job_status. See the Async Job Management tools.
Use the mcp_progress() helper in your MATLAB code:
mcp_progress(__mcp_job_id__, 50, 'Halfway done');This requires the __mcp_job_id__ variable, which is automatically available in async job contexts.
Yes, two ways:
-
Custom tools (recommended): Define them in
custom_tools.yamland they become first-class MCP tools with full parameter validation. See the Custom Tools example in the README. -
Path configuration: Add your function directories to
workspace.default_pathsin config, then call them viaexecute_code.
Yes! MATLAB figures are automatically converted to Plotly JSON, which renders as interactive charts in web-based clients. A static PNG and thumbnail are also generated as fallbacks. The conversion extracts axes, line data, labels, colors, markers, legends, and subplots.
Supported: Line, scatter, bar, area, subplots (subplot/tiledlayout), multiple axes, log/linear scales, and image plots.
Style preservation: Line styles (-- → dash), marker shapes (o → circle), colors (RGB), line widths, font sizes, axis labels, titles, legends, grid lines, axis limits, and background colors are all preserved.
Complex custom graphics may fall back to static PNG if the conversion cannot map the plot structure to Plotly.
Yes, three tools are available:
-
read_script— read.mscript files as text -
read_data— read data files (.mat,.csv,.json,.txt,.xlsx) withsummaryorrawmode -
read_image— read image files (.png,.jpg,.gif) as inline images that render in agent UIs
Use list_files first to see what files are available in your session.
Use the upload_data tool with base64-encoded content:
tool: upload_data
filename: my_data.csv
content_base64: <base64-encoded file content>
Files are stored in the session directory and can be referenced in MATLAB code.
Configure via pool.min_engines and pool.max_engines:
-
Personal use:
min: 1, max: 4(stdio transport) -
Small team (2-5 users):
min: 2, max: 8(SSE transport) - Larger team: Scale based on concurrent usage, up to your MATLAB license limit
On macOS, MATLAB limits you to ~4 concurrent engines due to system constraints.
Each engine is an independent MATLAB process. Running multiple engines uses memory proportional to the number of engines (typically 500MB-2GB per engine depending on loaded toolboxes). The pool automatically scales down idle engines after scale_down_idle_timeout (default 15 minutes).
Requests queue up (configurable queue_max_size, default 50). If the pool hasn't reached max_engines, a new engine is started proactively when utilization exceeds proactive_warmup_threshold (default 80%). Requests are served FIFO as engines become available.
Use the get_pool_status tool to check:
- Number of available, busy, and total engines
- Queue size
- Health status
For detailed metrics, use get_server_metrics which provides pool stats, job stats, session count, and system information. Use get_server_health to detect issues (healthy/degraded/unhealthy).
For SSE transport:
- Always put it behind an authenticating reverse proxy
- Set
require_proxy_auth: truein config - Bind to
127.0.0.1if the proxy is on the same machine - Configure
trusted_proxy_headersto validate X-Forwarded-For or X-Original-User headers
For stdio transport, the server only communicates with a single client and is not exposed to the network.
No. The security validator blocks system(), unix(), dos(), !, eval(), feval(), evalc(), evalin(), assignin(), perl(), and python() by default. You can customize the blocklist in execution.security.blocked_functions. Custom tools are pre-validated when defined in custom_tools.yaml.
Yes. When workspace_isolation: true (default), the workspace is fully cleared between sessions:
clear all; clear global; clear functions; fclose all; restoredefaultpathEach user gets a separate session directory with isolated files. SSE transport requires authentication to maintain session boundaries.
Code checking is available via the check_code tool, which runs MATLAB's checkcode/mlint before execution. Set execution.security.require_code_check: true in config to enforce this globally.
pip install -e ".[dev]"
pytest tests/ -vTests use a mock MATLAB engine — no MATLAB installation needed for testing.
- Create the implementation in
src/matlab_mcp/tools/ - Register it in
server.pywith@mcp.tooldecorator - Add tests in
tests/ - Update the MCP Tools Reference in documentation
Define them in custom_tools.yaml with MATLAB function references:
tools:
- name: my_tool
matlab_function: mylib.my_function
description: "Description for the agent"
parameters:
- name: param1
type: string
required: true
returns: "Description of return value"Custom tools are automatically validated and exposed as MCP tools.
Yes! Open an issue or PR on GitHub. Please include tests and documentation updates.
Install it from your MATLAB installation:
cd /Applications/MATLAB_R2024a.app/extern/engines/python
pip install .Verify installation:
python -c "import matlab.engine; print(matlab.engine.__version__)"Check the log file (default ./logs/server.log). Common issues:
- MATLAB Engine API not installed
- Port already in use (change
server.portin config) - MATLAB installation not found (set
pool.matlab_rootexplicitly)
Check job status with get_job_status. If a job is stuck:
- Cancel it with
cancel_job - Check
execution.async_timeoutin config (default 3600 seconds) - Review MATLAB code for infinite loops or missing
mcp_progress()calls
Complex custom graphics may not convert. Fallback to static PNG is automatic. For better conversion:
- Use standard MATLAB plot functions (
plot,scatter,bar, etc.) - Avoid custom graphics objects
- Simplify figure complexity if possible
Reduce pool.max_engines or the number of concurrent users. Each engine uses 500MB-2GB. Monitor system resources with get_server_metrics.
Ensure your MATLAB license supports concurrent engines. Use pool.max_engines to stay within license limits. Check MATLAB documentation for concurrent license requirements.