Skip to main content

MATLAB MCP Server

Ask DeepWiki

A Model Context Protocol (MCP) server that enables seamless integration between MATLAB and MCP-compatible applications like Claude Code. Execute MATLAB code, manage workspace variables, create plots, handle data I/O, and more - all through a token-efficient MCP interface.

Features

  • Execute MATLAB Code: Run MATLAB commands and scripts with persistent session
  • Workspace Management: Get, set, list, and clear workspace variables
  • Figure Operations: Save, export, and close MATLAB figures (PNG, SVG, PDF, etc.)
  • Data I/O: Import/export data (CSV, JSON, XLSX) and load/save MAT files
  • Environment Info: Check MATLAB version and installed toolboxes
  • Documentation Access: Get MATLAB help, search functions, and find toolbox locations
  • Token-Efficient Design: Multi-operation tools minimize API calls
  • JSON Resources: Structured access to workspace, toolboxes, and session info

Quick Start

Prerequisites:

  • MATLAB installed on your system
  • uv package manager installed (install uv)

Option 1: Zero-Installation Setup (Recommended)

Just configure and run - no manual installation needed!

1. Find your MATLAB library path:

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

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

2. Configure Claude Code:

Option A: Using CLI (Recommended)

# macOS (Apple Silicon)
claude mcp add --transport stdio matlab \
  --env DYLD_LIBRARY_PATH=/Applications/MATLAB_R2025b.app/bin/maca64 \
  -- uvx matlab-mcp-server

# Linux
claude mcp add --transport stdio matlab \
  --env LD_LIBRARY_PATH=/usr/local/MATLAB/R2024b/bin/glnxa64 \
  -- uvx matlab-mcp-server

This uses local scope by default (private to you, only this project). For other scopes:

  • --scope project: Share with team (stores in .mcp.json, can be committed to git)
  • --scope user: Available across all your projects

Option B: Manual .mcp.json file

Create .mcp.json in your project root directory:

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

Replace the library path with your actual MATLAB path from step 1.

For Linux, use LD_LIBRARY_PATH instead of DYLD_LIBRARY_PATH.

That's it! When Claude Code starts, uvx will automatically:

  • Download matlab-mcp-server from PyPI
  • Install matlabengine and all dependencies
  • Start the MATLAB MCP server

Option 2: Configuration Helper (If you don't know your MATLAB path)

Run the helper script to auto-detect MATLAB and display the config:

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

The script will:

  • Auto-detect your MATLAB installation
  • Display the config with the correct paths
  • You copy and paste it into your .mcp.json file (in project root)

Option 3: Manual Installation

If you prefer to install manually or the automated installer doesn't work:

1. Install matlabengine

# Navigate to your MATLAB Python engine directory
cd /Applications/MATLAB_R20XXx.app/extern/engines/python  # macOS
# OR
cd /usr/local/MATLAB/R20XXx/extern/engines/python  # Linux

# Install using uv
uv pip install .

Replace R20XXx with your MATLAB version (e.g., R2024a, R2024b, R2025a).

2. Install matlab-mcp-server

uv pip install matlab-mcp-server

3. Configure MCP server

Create .mcp.json in your project root directory:

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"
      }
    }
  }
}

Replace R20XXx with your actual MATLAB version.

Note for Claude Desktop users: If you're using Claude Desktop (the desktop app) instead of Claude Code (CLI), the configuration file is located at:

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

Available Tools

The server provides 8 MCP tools for interacting with MATLAB:

  • execute_matlab - Execute MATLAB code and get results
  • workspace - Manage workspace variables (get, set, list, clear)
  • figure - Save, export, and manage MATLAB figures (PNG, SVG, PDF, etc.)
  • data_io - Import/export data in various formats (CSV, JSON, XLSX, MAT files)
  • env - Get MATLAB version and check installed toolboxes
  • get_help - Access MATLAB documentation and search functions
  • route_intent - Suggest appropriate tool mode (meta-tool)
  • select_mode - Enable optional tool groups (meta-tool)

For detailed documentation on each tool, see TOOLS.md or MATLAB_MCP_GUIDE.md.

Troubleshooting

MATLAB Engine Not Found

If you get an error about MATLAB engine not being found:

  1. Ensure MATLAB is properly installed
  2. Verify MATLAB Engine API for Python is installed
  3. Check Python version matches MATLAB compatibility
  4. Verify library path is correctly set in config

Library Path Issues

Default MATLAB locations:

  • macOS: /Applications/MATLAB_R20XXx.app
  • Linux: /usr/local/MATLAB/R20XXx
  • Windows: C:\Program Files\MATLAB\R20XXx

If MATLAB is in a non-standard location, update the library path in your config.

Documentation

License

MIT License

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for development setup and guidelines.

Star History

Star History Chart

Metadata

Release files for matlab-mcp-server 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matlab-mcp-server 0.2.3
File Size Uploaded
matlab_mcp_server-0.2.3.tar.gz 81.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matlab-mcp-server 0.2.3
File Interpreter ABI Platform
matlab_mcp_server-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 101.1 kB

Release files / matlab_mcp_server-0.2.3.tar.gz

Download URL matlab_mcp_server-0.2.3.tar.gz
Size 81.8 kB
Tags Source
SHA-256 checksum
How to use checksums
36f48f2108117c2aa1fea2f949ea58fc1520b0b810c442c855a6c87353d18661
BLAKE2b-256 checksum
How to use checksums
45651a4e310e43c20800c4cc422de773b19e0f25a4286b571a0206762261e7d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release files / matlab_mcp_server-0.2.3-py3-none-any.whl

Download URL matlab_mcp_server-0.2.3-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7f34b90198f5b6d00a5b8e65b9064ccc36acad5cfc7300b1e45d5c5957c8d5f
BLAKE2b-256 checksum
How to use checksums
c8cf6c767d384c90deeeaf25cd1e3356bfc3c022e5463bf5384fe33a3fc14228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page