-
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 Installation section in the README.
Note: If you previously installed as
matlab-mcp-server, uninstall first:pip uninstall matlab-mcp-server && pip install matlab-mcp-python
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 up (edit docker-compose.yml to set your MATLAB path).
cd /Applications/MATLAB_R2024a.app/extern/engines/python # macOS
# cd "C:\Program Files\MATLAB\R2024a\extern\engines\python" # Windows
pip install .Adjust the path for your MATLAB version and OS.
- stdio: Single user, simple setup. The AI agent launches the server process directly. Use this for personal or Cursor/Claude Desktop integration.
- SSE: Multiple users, shared server. Users connect over HTTP with session isolation. Requires more setup but supports concurrent access and multiple agents. Use this for team environments.
Start with:
matlab-mcp # stdio (default)
matlab-mcp --transport sse # SSE (multi-user)Yes, with SSE transport. Start the server on a remote machine and connect via HTTP. Always put it behind an authenticating reverse proxy for production use. Configure require_proxy_auth: true in config.yaml and bind to 127.0.0.1 if the proxy is on the same machine.
All settings are in config.yaml with sensible defaults. Override any setting via environment variables:
export MATLAB_MCP_POOL_MIN_ENGINES=4
export MATLAB_MCP_POOL_MAX_ENGINES=16
export MATLAB_MCP_EXECUTION_SYNC_TIMEOUT=60
export MATLAB_MCP_SERVER_TRANSPORT=sseKey sections: server (transport, host, port, logging), pool (engine scaling), execution (timeouts, workspace isolation), security (code blocklist), and workspace (default paths).
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. Retrieve full results with get_job_result when done.
Use the mcp_progress() helper in your MATLAB code:
mcp_progress(__mcp_job_id__, 50, 'Halfway done');Progress updates are tracked and returned via get_job_status.
Yes, two ways:
-
Custom tools (recommended): Define them in
custom_tools.yamland they become first-class MCP tools with parameter validation and help text. See the README for examples. -
Path configuration: Add your function directories to
workspace.default_pathsinconfig.yaml, then call them viaexecute_code.
Yes! MATLAB figures are automatically converted to interactive Plotly JSON, which renders as interactive charts in web-based clients. A static PNG and thumbnail are also generated as fallback for non-interactive clients.
- Supported: Line, scatter, bar, area, histogram, surface, image plots
-
Advanced: Subplots (
subplotandtiledlayout), multiple axes, log/linear scales, colormaps -
Style fidelity: Line styles (
--→dash,-.→dot), marker shapes (o→circle), colors (RGB), line widths, font sizes, axis labels, titles, legends, grid lines, and background colors
Complex custom graphics or 3D plots may fall back to static PNG.
Yes, three tools are available:
-
read_script— read.mscript files as text -
read_data— read data files (.mat,.csv,.json,.txt,.xlsx) withsummaryorrawformat -
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.
Yes, use upload_data to upload files (base64 encoded). Delete files with delete_file.
Use check_code to run MATLAB's built-in checkcode/mlint. It returns structured warnings and errors without executing anything.
-
Personal use: 1-2 engines (set
min_engines: 1, max_engines: 2) - Small team (2-5 users): 2-4 engines
- Larger team: Scale based on concurrent usage, up to your MATLAB license limit
The pool automatically scales between min_engines and max_engines based on demand. On macOS, MATLAB limits you to ~4 concurrent engines.
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). System performance depends on your hardware.
Requests queue up (configurable queue_max_size, default 50). If the pool hasn't reached max_engines, a new engine is started proactively (threshold configurable via proactive_warmup_threshold). Requests are served FIFO as engines become available.
Use these tools:
-
get_pool_status— Engine pool stats (available, busy, max) -
get_server_metrics— Comprehensive metrics (pool, jobs, sessions, system resources) -
get_server_health— Health status with issue detection (healthy/degraded/unhealthy) -
get_error_log— Recent errors and notable events
For SSE transport:
- Always put it behind an authenticating reverse proxy
- Set
require_proxy_auth: trueinconfig.yaml - Bind to
127.0.0.1if the proxy is on the same machine - Use HTTPS in production
No. The security validator blocks dangerous functions by default:
-
system(),unix(),dos(),!— shell execution -
eval(),feval(),evalc(),evalin()— dynamic code execution -
assignin()— workspace manipulation -
perl(),python()— external process execution
You can customize the blocklist in security.blocked_functions in config.yaml. Code is checked before execution via check_code.
Yes. When workspace_isolation: true (default), the workspace is fully cleared between sessions:
clear all; clear global; clear functions; fclose all; restoredefaultpathEach SSE client gets its own isolated workspace.
You can customize security.blocked_functions in config.yaml to remove functions from the blocklist, but this is not recommended for untrusted agents. Use custom tools instead to safely expose your MATLAB code.
Cause: MATLAB Engine API not installed or not on the Python path.
Fix:
cd /Applications/MATLAB_R2024a.app/extern/engines/python # macOS
pip install .Verify with: python -c "import matlab.engine; print('OK')"
Cause: MATLAB installation path not found, licensing issue, or insufficient system resources.
Fix:
- Verify MATLAB is installed:
which matlabor checkC:\Program Files\MATLAB - Set explicit path:
export MATLAB_MCP_POOL_MATLAB_ROOT=/path/to/MATLAB - Check MATLAB license:
matlab -r "license('test'); quit" - Increase timeout:
export MATLAB_MCP_POOL_ENGINE_START_TIMEOUT=180 - Check logs:
tail -f logs/server.log
Cause: Code contains syntax errors, undefined variables, or blocked functions.
Fix:
- Use
check_codefirst to validate syntax - Run simpler code to isolate the issue
- Check logs for full error messages:
log_level: "debug"inconfig.yaml - Ensure required toolboxes are installed: use
list_toolboxes
Cause: Job ID expired or wrong session.
Fix:
- Use
list_jobsto see all active jobs - Check job status with
get_job_statusbefore results are ready - Retrieve results with
get_job_result(not from MATLAB directly)
Cause: Unsupported plot type, corrupted figure, or extraction failed.
Fix:
- Use supported plot types: line, scatter, bar, histogram, surface, image
- Check for custom graphics objects or nested figures
- Add explicit axis labels and titles for better conversion
- PNG fallback always works — plots are never lost
Cause: MATLAB path not mounted correctly or environment variable not set.
Fix:
docker run -e MATLAB_MCP_POOL_MATLAB_ROOT=/opt/matlab \
-v /Applications/MATLAB_R2024a.app:/opt/matlab:ro \
matlab-mcpVerify with: docker exec <container> ls /opt/matlab
Cause: Network latency, proxy timeouts, or high server load.
Fix:
- Check
get_server_healthfor degraded status - Scale engines:
max_engines> current demand - Increase drain timeout:
server.drain_timeout_seconds: 600 - Monitor reverse proxy logs for dropped connections
Cause: Corrupted engine state or locked files/processes.
Fix:
- Disable isolation temporarily to diagnose:
workspace_isolation: false(dev only) - Restart the engine pool: scale to 0 then back up
- Check for open file handles:
fopen('all')in your code
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 the@mcp.tooldecorator - Add tests in
tests/ - Update the README MCP Tools Reference table
Yes! Open an issue or PR on GitHub. Check the README for development setup and the wiki for design docs.