matlab/matlab-mcp-server

Run MATLAB® using AI applications with the official MATLAB MCP Server from MathWorks®. This MCP server for MATLAB supports a wide range of coding agents like Claude Code® and Visual Studio® Code.

MATLAB MCP Server — Explainer

What is it?

An official tool from MathWorks that lets AI coding assistants (like Claude Code, GitHub Copilot, and OpenAI Codex) start and control MATLAB directly. Instead of you copying code back and forth, the AI can run MATLAB code, check it for errors, and get results automatically.

What can it do?

  • Start and quit MATLAB — the AI can launch a MATLAB session and close it when done.
  • Write and run MATLAB code — the AI can send code to MATLAB and receive the output.
  • Assess code quality — the AI can check a MATLAB script for style issues, potential bugs, deprecated functions, and performance problems without actually running it.

How does it work?

It uses the Model Context Protocol (MCP) — a standard way for AI applications to connect to external tools. The server acts as a bridge: your AI assistant talks to it, and it talks to MATLAB on your computer.

Installation options

  • Recommended: Use the Agentic Toolkit Installer — a separate tool that automatically configures the server for Claude Code, GitHub Copilot CLI, or OpenAI Codex.
  • Manual: Download a pre-built binary (or build from source with Go), then add it to your AI application's configuration. The README gives step-by-step instructions for Claude Code, Claude Desktop, GitHub Copilot in VS Code, and Codex.

Requirements

  • MATLAB R2021a or later, added to your system's PATH.
  • The server works on Windows, Linux, and macOS (with separate downloads for Apple silicon vs. Intel Macs).

Configuration options (Arguments)

You can customize the server with command-line flags, config files, or environment variables. Key options include:

  • --matlab-root — which MATLAB installation to use (default: first one on PATH).
  • --initial-working-folder — where MATLAB starts (default: your home or Documents folder).
  • --matlab-display-mode — show the MATLAB desktop (desktop, default) or run headless (nodesktop).
  • --matlab-session-mode — start a new MATLAB session (new), connect to an existing one (existing), or try existing first then fall back to new (auto, default).
  • --extension-file — load custom MCP tools from a JSON file.
  • --log-folder / --log-level — control where and how much logging happens.
  • --disable-telemetry — turn off anonymized usage data collection (on by default).
  • --help / --version — basic info.

Tools (what the AI can call)

  1. detect_matlab_toolboxes — lists installed MATLAB toolboxes and version numbers.
  2. check_matlab_code — static analysis of a .m file; returns warnings about style, errors, deprecated functions, performance, and best practices. Read-only — never modifies the file.
  3. evaluate_matlab_code — runs a string of MATLAB code and returns the output. Takes a code string and a project_path (the working folder).
  4. run_matlab_file — executes a .m or .p script file and returns output. If both a .m and .p with the same name exist, MATLAB runs the .p.
  5. run_matlab_test_file — runs a MATLAB unit test file and returns comprehensive test results.

Resources (reference material for the AI)

The server provides two built-in reference documents the AI can consult to write better MATLAB code:

  1. matlab_coding_guidelines — coding standards covering naming, formatting, commenting, performance, and error handling.
  2. plain_text_live_code_guidelines — rules for generating live scripts in plain-text .m format (requires MATLAB R2025a+ to run).

Data collection

By default, the server sends fully anonymized usage data to MathWorks to help improve products. Turn it off with --disable-telemetry=true.

Security notes

The README warns to review and validate all tool calls before running them — keep a human in the loop, since the AI can execute arbitrary MATLAB code.

Licensing

  • License is in the repo's LICENSE.md file.
  • MCP servers may only be used with MATLAB per the MathWorks Software License Agreement.
  • Not allowed for shared/multi-user use — contact MathWorks if you need that.

Support

File issues on GitHub or contact MathWorks Technical Support.

Related

  • Project
  • Project
  • Project
  • Project
  • Project