MATLAB

The MATLAB MCP Server creates a direct connection between MATLAB and AI assistants like Claude Code and Cursor AI.

It provides programmatic access to MATLAB’s computational engine, workspace management, and visualization capabilities through a standardized protocol interface.

Features

  • Execute MATLAB code with persistent session state
  • 🧮 Manage workspace variables – get, set, list, and clear
  • 📊 Handle figures – save, export, and close plots in multiple formats
  • 📁 Data I/O operations – import/export CSV, JSON, XLSX, and MAT files
  • 🔍 Access documentation – search functions and get MATLAB help
  • 📋 Environment information – check version and installed toolboxes
  • 🎯 Token-efficient design – multi-operation tools reduce API calls
  • 📚 JSON resources – structured access to workspace and session data

Use Cases

  • Interactive Data Analysis: You can ask your AI assistant to load a dataset, perform a statistical analysis, and generate a plot. The server runs the code in MATLAB and returns the resulting figure directly to your chat, which you can then ask to modify.
  • Rapid Algorithm Prototyping: Describe a complex algorithm in plain English and have the AI generate the MATLAB code. The server can execute it immediately, and if there are errors, the AI can debug them based on the output.
  • Automating Tedious Tasks: If you need to process a folder full of data files, you can simply instruct the AI on the steps. It can use the server’s tools to write a script, loop through the files, perform the necessary operations, and save the results.
  • Learning and Exploration: When you’re unfamiliar with a toolbox, you can ask the AI for help. For example, “How do I perform a fast Fourier transform on a vector named audio_signal?”. The server can use the get_help tool to pull the official MATLAB documentation for the fft function and the AI can use that context to generate a correct, executable example for you.

How to Use It

Before you start, you need MATLAB installed on your system and the uv package manager.

Zero-Installation Setup (Recommended)

This approach uses uvx to run the server without a permanent installation. It automatically downloads and caches the necessary packages on the first run.

1. Find your MATLAB library path.

This path is crucial for the server to connect to MATLAB.

  • macOS (Apple Silicon): /Applications/MATLAB_R2025b.app/bin/maca64
  • Linux: /usr/local/MATLAB/R2024b/bin/glnxa64

You must replace the version number (e.g., R2025b) with the one you have installed.

2. Configure Claude Code.

You can do this from the command line or by creating a configuration file.

Using the CLI:

This command adds the server configuration with a local scope, meaning it’s only active for the current project.

# macOS (Apple Silicon)
/Applications/MATLAB_R2025b.app/bin/maca64

# Linux
/usr/local/MATLAB/R2024b/bin/glnxa64

You can change the scope by adding --scope project to share it with your team (via a .mcp.json file) or --scope user to make it available across all your projects.

Manual .mcp.json file:

Create a file named .mcp.json in your project’s root directory.

{
  "mcpServers": {
    "matlab": {
      "command": "uvx",
      "args": ["matlab-mcp-server"],
      "env": {
        "DYLD_LIBRARY_PATH": "/Applications/MATLAB_R2025b.app/bin/maca64"
      }
    }
  }
}

Remember to use LD_LIBRARY_PATH for Linux systems and update the path to your specific MATLAB installation.

Option 2: Configuration Helper

If you are not sure where MATLAB is installed, you can run this helper script. It will try to find your MATLAB installation and print the correct JSON configuration for you to copy.

curl -fsSL https://raw.githubusercontent.com/subspace-lab/matlab-mcp-server/main/install-matlab-mcp.sh | bash

Option 3: Manual Installation

If you prefer to manage the installation yourself, follow these steps.

1. Install the MATLAB Engine for Python.

Navigate to the Python engine directory within your MATLAB installation and install it.

# For macOS
cd /Applications/MATLAB_R20XXx.app/extern/engines/python
# For Linux
cd /usr/local/MATLAB/R20XXx/extern/engines/python
# Install with uv
uv pip install .

Replace R20XXx with your MATLAB version.

2. Install the MCP Server.

uv pip install matlab-mcp-server

3. Configure the MCP server.

Create a .mcp.json file in your project root with the correct command and environment variable.

// macOS (Apple Silicon)
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp",
"env": {
"DYLD_LIBRARY_PATH": "/Applications/MATLAB_R20XXx.app/bin/maca64"
}
}
}
}

// macOS (Intel):
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp",
"env": {
"DYLD_LIBRARY_PATH": "/Applications/MATLAB_R20XXx.app/bin/maci64"
}
}
}
}

// Linux:
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp",
"env": {
"LD_LIBRARY_PATH": "/usr/local/MATLAB/R20XXx/bin/glnxa64"
}
}
}
}

Note for Claude Desktop Users: If you use the Claude Desktop application, the configuration file is located in a different place:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Available Tools

The server exposes eight tools to your AI assistant:

  • execute_matlab: Executes MATLAB code.
  • workspace: Manages workspace variables.
  • figure: Handles saving and exporting plots.
  • data_io: Manages data import and export.
  • env: Gets information about the MATLAB environment.
  • get_help: Fetches documentation for MATLAB functions.
  • route_intent: A meta-tool that helps the AI choose the right tool.
  • select_mode: A meta-tool to enable optional tool groups.

FAQs

Q: Can I use this with older MATLAB versions?
A: The server works with MATLAB versions that support the Python Engine API. Check your MATLAB documentation for Python compatibility, as older versions may have limitations.

Q: What’s the difference between uvx installation and manual installation?
A: uvx automatically downloads and runs the latest version without permanent installation, while manual installation gives you more control over the environment and dependencies.

Q: How does the persistent session work?
A: The server maintains a single MATLAB session across multiple operations, preserving your workspace variables, figures, and state until the server is restarted or the session is explicitly cleared.

Latest MCP Servers

Excalidraw

Excalidraw's official MCP server that streams interactive hand-drawn diagrams to Claude, ChatGPT, and VS Code with smooth camera control and fullscreen editing.

Claude Context Mode

This MCP Server compresses tool outputs by 98% using sandboxed execution, full-text search with BM25 ranking, and multi-language support for Claude Code.

Context+

An MCP server provides AST parsing, semantic search, and feature graph tools for large codebases with 99% accuracy.

View More MCP Servers >>

Featured MCP Servers

Excalidraw

Excalidraw's official MCP server that streams interactive hand-drawn diagrams to Claude, ChatGPT, and VS Code with smooth camera control and fullscreen editing.

Claude Context Mode

This MCP Server compresses tool outputs by 98% using sandboxed execution, full-text search with BM25 ranking, and multi-language support for Claude Code.

Context+

An MCP server provides AST parsing, semantic search, and feature graph tools for large codebases with 99% accuracy.

More Featured MCP Servers >>

FAQs

Q: What exactly is the Model Context Protocol (MCP)?

A: MCP is an open standard, like a common language, that lets AI applications (clients) and external data sources or tools (servers) talk to each other. It helps AI models get the context (data, instructions, tools) they need from outside systems to give more accurate and relevant responses. Think of it as a universal adapter for AI connections.

Q: How is MCP different from OpenAI's function calling or plugins?

A: While OpenAI's tools allow models to use specific external functions, MCP is a broader, open standard. It covers not just tool use, but also providing structured data (Resources) and instruction templates (Prompts) as context. Being an open standard means it's not tied to one company's models or platform. OpenAI has even started adopting MCP in its Agents SDK.

Q: Can I use MCP with frameworks like LangChain?

A: Yes, MCP is designed to complement frameworks like LangChain or LlamaIndex. Instead of relying solely on custom connectors within these frameworks, you can use MCP as a standardized bridge to connect to various tools and data sources. There's potential for interoperability, like converting MCP tools into LangChain tools.

Q: Why was MCP created? What problem does it solve?

A: It was created because large language models often lack real-time information and connecting them to external data/tools required custom, complex integrations for each pair. MCP solves this by providing a standard way to connect, reducing development time, complexity, and cost, and enabling better interoperability between different AI models and tools.

Q: Is MCP secure? What are the main risks?

A: Security is a major consideration. While MCP includes principles like user consent and control, risks exist. These include potential server compromises leading to token theft, indirect prompt injection attacks, excessive permissions, context data leakage, session hijacking, and vulnerabilities in server implementations. Implementing robust security measures like OAuth 2.1, TLS, strict permissions, and monitoring is crucial.

Q: Who is behind MCP?

A: MCP was initially developed and open-sourced by Anthropic. However, it's an open standard with active contributions from the community, including companies like Microsoft and VMware Tanzu who maintain official SDKs.

Get the latest & top AI tools sent directly to your email.

Subscribe now to explore the latest & top AI tools and resources, all in one convenient newsletter. No spam, we promise!