/ Directory / Playground / MATLAB
● Official matlab 🔑 Needs your key

MATLAB

by matlab · matlab/matlab-mcp-core-server

Run MATLAB code, tests, and toolboxes from your AI agent — official MathWorks MCP.

MathWorks' official MATLAB MCP. Lets an agent evaluate MATLAB expressions, run .m script files, execute unit tests, and detect installed toolboxes. Bridges LLM reasoning with numerical/simulation workloads that live in MATLAB.

Why use it

Key features

Live Demo

What it looks like in practice

matlab.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "matlab": {
      "command": "uvx",
      "args": [
        "matlab-mcp-core-server"
      ]
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "matlab": {
      "command": "uvx",
      "args": [
        "matlab-mcp-core-server"
      ]
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "matlab": {
      "command": "uvx",
      "args": [
        "matlab-mcp-core-server"
      ]
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "matlab": {
      "command": "uvx",
      "args": [
        "matlab-mcp-core-server"
      ]
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "matlab",
      "command": "uvx",
      "args": [
        "matlab-mcp-core-server"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "matlab": {
      "command": {
        "path": "uvx",
        "args": [
          "matlab-mcp-core-server"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add matlab -- uvx matlab-mcp-core-server

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use MATLAB

Generate, analyze, and run a MATLAB script

👤 Engineering researchers, controls/DSP engineers ⏱ ~20 min intermediate

When to use: You want to prototype a computation in MATLAB conversationally — generate, run, tune, repeat.

Prerequisites
  • MATLAB R2020b+ installed and on PATHmatlab -help from a terminal should work
  • MATLAB registered as Personal Automation Servermatlab.engine.shareEngine in MATLAB once — see MCP README
Flow
  1. Check capabilities
    Detect installed MATLAB toolboxes. I need Signal Processing and Control System.✓ Copied
    → List with versions; agent knows what it can use
  2. Generate the script
    Write a MATLAB script that loads signal.mat, applies a Butterworth lowpass at 50Hz, plots before/after. Save as ./lp_filter.m.✓ Copied
    → .m file written
  3. Check then run
    Run check_matlab_code on lp_filter.m. Fix any issues. Then run_matlab_file and return the plot path.✓ Copied
    → Static checks pass, script runs, output figure saved

Outcome: Working MATLAB prototypes in minutes without switching windows.

Pitfalls
  • Relative paths break — MATLAB starts in its own working dir — Always use absolute paths in script_path and inside the script itself; or cd to your dir as the first line
  • Script hangs on uiopen/plot windows in non-interactive mode — Use figure('Visible','off') and saveas() to file instead of displaying
Combine with: filesystem

Run MATLAB unit tests and iterate on failures

👤 Engineers maintaining MATLAB codebases ⏱ ~20 min intermediate

When to use: You have a test suite (matlab.unittest) and want the agent to run it and help fix regressions.

Prerequisites
  • Test file using matlab.unittest — Classes inheriting from matlab.unittest.TestCase
Flow
  1. Run the suite
    Run tests in ./tests/MyAlgorithmTest.m. Return per-method pass/fail plus any error text.✓ Copied
    → Structured test report
  2. Diagnose
    For each failure, read the assertion, read the implementation, explain the gap.✓ Copied
    → Per-failure root cause
  3. Fix and re-run
    Apply minimal fixes to the implementation (not tests). Re-run until green.✓ Copied
    → All tests pass

Outcome: TDD loop over MATLAB code driven by the agent.

Pitfalls
  • Tests depend on files not on the MATLAB path — Add addpath(genpath(pwd)) at test start, or pass project_path explicitly

Combinations

Pair with other MCPs for X10 leverage

matlab + filesystem

Read data files → run MATLAB computation → save result files

Read ./data/*.csv, write a MATLAB script that processes each, save outputs to ./processed/. Run and confirm.✓ Copied
matlab + git

Version-control the scripts the agent generates

Generate the MATLAB analysis script, run it, verify results look good, then commit the script with a descriptive message.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
detect_matlab_toolboxes First step — know what you can use free
check_matlab_code script_path (absolute) Lint before running — catches obvious issues fast free
evaluate_matlab_code code: str, project_path (absolute) One-off expression or inline code free
run_matlab_file script_path (absolute) Execute a saved .m file free
run_matlab_test_file script_path (absolute) Structured test execution free

Cost & Limits

What this costs to run

API quota
None — local MATLAB execution
Tokens per call
Script outputs can be large (plots, tables). Cap returned data.
Monetary
MATLAB license required (not free); MCP itself is free
Tip
Have the agent write plots to files instead of returning big numeric matrices in responses

Security

Permissions, secrets, blast radius

Credential storage: None — local execution
Data egress: None — MATLAB runs locally

Troubleshooting

Common errors and fixes

'MATLAB engine not found' on first call

Register MATLAB as a Personal Automation Server: in MATLAB run matlab.engine.shareEngine. Restart the MCP after.

Verify: From terminal: `python -c 'import matlab.engine; matlab.engine.find_matlab()'` — should list engines
Scripts error with 'Undefined function'

The function is in a toolbox that isn't installed, or not on the MATLAB path. Run detect_matlab_toolboxes and confirm.

check_matlab_code reports nothing but runtime fails

mlint catches syntax not semantics. Use evaluate_matlab_code with a small test input to validate logic.

Long-running script times out

MCP clients have per-call timeouts. Break the script into stages, saving intermediate results to disk; run stage-by-stage.

Alternatives

MATLAB vs others

AlternativeWhen to use it insteadTradeoff
Octave via shell MCPYou don't have a MATLAB license and need open-sourceSyntax-compatible for core, but toolboxes often differ significantly
Python (numpy/scipy) via a Python-exec MCPYou're willing to translate the workflowFree, huge ecosystem, but you give up MATLAB-specific toolboxes (Simulink, etc.)

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills