home / mcp / matlab mcp tools server

MATLAB MCP Tools Server

Provides MATLAB execution and section-based scripting via MCP for interactive development and plotting.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "neuromechanist-matlab-mcp-tools": {
      "command": "matlab-mcp-server",
      "args": [],
      "env": {
        "PATH": "${MATLAB_PATH}/bin:${PATH}",
        "MATLAB_PATH": "${MATLAB_PATH}"
      }
    }
  }
}

You run a MATLAB MCP Server to develop and run MATLAB files interactively. It integrates with MCP-compatible clients to execute scripts, run specific sections, capture plots, and inspect the MATLAB workspace, all while preserving context between executions.

How to use

Start the MATLAB MCP Server and connect it with an MCP client such as Cursor or Claude Code. The server exposes tools to execute entire MATLAB scripts, run individual sections, retrieve script section information, create new scripts, and inspect the current MATLAB workspace. Use these tools to develop MATLAB code in small steps, visualize plots, and maintain workspace state across commands.

How to install

Prerequisites you need before installing the MATLAB MCP Server are Python 3.10 or newer, MATLAB with Python Engine installed, and the uv package manager.

# Quick Start (Recommended)
./install-matlab-mcp.sh

# The installer auto-detects MATLAB, installs UV if needed,
# creates a MATLAB-compatible Python virtual environment,
# installs dependencies including the MATLAB Python engine,
# generates MCP configuration, and can configure Cursor automatically.

If you need a custom setup, you can run the installer manually after configuring your environment.

# Optional: set custom MATLAB path if MATLAB is in an unusual location
export MATLAB_PATH=/path/to/your/matlab/installation

# Run the installer
./install-matlab-mcp.sh

Legacy installation (Manual)

Legacy steps are provided for environments where the standard installer cannot be used. Follow these steps in order to prepare the environment and install the server components manually.

# 1. Install UV package manager (choose one)
# Install UV via Homebrew
brew install uv

# Or install via pip
pip install uv
```
```bash
# 2. Set MATLAB path environment variable (optional - auto-detects in common locations)
export MATLAB_PATH=/Applications/MATLAB_R2024b.app

# For Windows (Git Bash)
export MATLAB_PATH="C:/Program Files/MATLAB/R2024b"
```
```bash
# 3. Run legacy setup script
./scripts/setup-matlab-mcp.sh
```
```bash
# 4. Configure Cursor manually
cp mcp-pip.json ~/.cursor/mcp.json
```
"

Testing installation

Test your installation to ensure the server starts correctly and the available tools respond as expected.

./scripts/test-matlab-mcp.sh

Available tools

execute_script

Execute a complete MATLAB script or a script file, returning results and any plots generated.

execute_script_section

Execute a specific range of sections within a MATLAB script, preserving workspace state between sections.

get_script_sections

Retrieve information about the sections defined in a MATLAB script, including section boundaries and names.

create_matlab_script

Create a new MATLAB script with a template to start development quickly.

get_workspace

Query the current MATLAB workspace variables and their values.