Skip to content
github-actions[bot] edited this page Mar 18, 2026 · 21 revisions

MATLAB MCP Server Wiki

Welcome to the MATLAB MCP Server wiki! This server connects any AI agent to a shared MATLAB installation via the Model Context Protocol (MCP).

Quick Navigation

  • Installation — Prerequisites, MATLAB Engine API, server setup
  • Configuration — Full YAML config reference with all options
  • MCP Tools Reference — All built-in tools with parameters and examples
  • Custom Tools — Expose your own .m functions as AI-callable tools
  • Examples — Ready-to-run MATLAB examples for common tasks
  • Architecture — System design, engine pool, async jobs, session model
  • Async Jobs — Long-running jobs, progress reporting, job lifecycle
  • Security — Function blocklist, workspace isolation, upload limits
  • Troubleshooting — Common issues and solutions
  • FAQ — Frequently asked questions

What is this?

A Python MCP server that gives AI agents (Claude, Cursor, Copilot, custom agents) the ability to:

  • Execute MATLAB code — sync for fast commands, async for long-running jobs
  • Discover toolboxes — browse installed toolboxes, functions, and help text
  • Check code quality — run checkcode/mlint before execution
  • Get interactive plots — figures auto-converted to Plotly JSON with full style fidelity
  • Use custom libraries — expose your .m/.mex functions as first-class MCP tools
  • Run multi-user — session isolation with an elastic engine pool (2-10+ engines)

Key Features

Feature Description
Execute MATLAB code Sync for fast commands, auto-async for jobs >30s
Elastic engine pool Scales 2-10+ engines based on demand
Toolbox discovery Browse installed toolboxes, functions, help text
Code checker Run checkcode/mlint before execution
Interactive plots MATLAB figures → Plotly JSON with line styles, colors, markers, legends
Multi-user (SSE) Session isolation with per-user workspaces
Custom tools Expose your .m functions as MCP tools via YAML
Progress reporting Long jobs report percentage back to the agent
Job management Cancel, query status, retrieve results of async jobs

Supported Platforms

Platform MATLAB Version Transport
macOS 2020b+ stdio, SSE
Windows 2020b+ stdio, SSE
Docker 2020b+ stdio, SSE

Quick Start

Install

# From PyPI
pip install matlab-mcp-python

# From source
git clone https://github.com/HanSur94/matlab-mcp-server-python.git
cd matlab-mcp-server-python
pip install -e ".[dev]"

Run

# Single user (stdio)
matlab-mcp

# Multi-user (SSE)
matlab-mcp --transport sse

Connect to Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "matlab": {
      "command": "matlab-mcp"
    }
  }
}

Example: AI Agent Calls MATLAB

Ask your AI agent:

"Calculate eigenvalues of a 3x3 magic square and plot it"

The agent executes:

A = magic(3);
eigenvalues = eig(A);
imagesc(A); colorbar;
title('Magic Square');

You get:

  • Inline result: 15.0000, 4.8990, -4.8990
  • Interactive Plotly chart with colors, axis labels, legend

Getting Help

Clone this wiki locally