MATLAB MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MATLAB MCP Serverplot a sine wave from 0 to 2π"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MATLAB MCP Server
This Model Context Protocol (MCP) server provides integration with MATLAB, allowing you to create and execute MATLAB scripts and functions through Claude or other MCP clients.
Setup Requirements
Python 3.11 (Python 3.13 and 3.12 are not currently supported by MATLAB Engine)
MATLAB R2024a (or compatible version)
uv package manager
Related MCP server: MATLAB MCP Server
Installation
Create and set up the Python environment:
# Pin Python version
uv python pin 3.11
# Create virtual environment
uv venv
# Activate virtual environment
source .venv/bin/activate
# Install MCP
uv add "mcp[cli]"Install MATLAB Engine The MATLAB Engine will be installed automatically when the server first runs, using the MATLAB installation specified in the
MATLAB_PATHenvironment variable.
Directory Structure
matlab_server.py: The main MCP server implementationmatlab_scripts/: Directory where all MATLAB scripts and functions are saved (created automatically)pyproject.toml: Python project configuration.python-version: Specifies Python version for uv
Claude Desktop Integration
Open your Claude Desktop configuration:
# On macOS
code ~/Library/Application\ Support/Claude/claude_desktop_config.jsonAdd the MATLAB server configuration:
{
"mcpServers": {
"matlab": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/matlab-mcp",
"run",
"matlab_server.py"
],
"env": {
"MATLAB_PATH": "/Applications/MATLAB_R2024a.app"
}
}
}
}Make sure to:
Replace
/absolute/path/to/matlab-mcpwith the actual path to your project directoryVerify the
MATLAB_PATHpoints to your MATLAB installationUse absolute paths (not relative)
Features
The server provides several tools:
create_matlab_script: Create a new MATLAB script fileScripts are saved in the
matlab_scriptsdirectoryFile names must be valid MATLAB identifiers
create_matlab_function: Create a new MATLAB function fileFunctions are saved in the
matlab_scriptsdirectoryMust include valid function definition
execute_matlab_script: Run a MATLAB script and get resultsReturns output text, generated figures, and workspace variables
Can pass arguments to scripts
call_matlab_function: Call a MATLAB function with argumentsReturns function output and any generated figures
Testing
You can test the server using the MCP Inspector:
# Make sure you're in your virtual environment
source .venv/bin/activate
# Run the inspector
MATLAB_PATH=/Applications/MATLAB_R2024a.app mcp dev matlab_server.pyExample test script:
t = 0:0.01:2*pi;
y = sin(t);
plot(t, y);
title('Test Plot');
xlabel('Time');
ylabel('Amplitude');Script Storage
All MATLAB scripts and functions are saved in the
matlab_scriptsdirectoryThis directory is created automatically when the server starts
Files are named
<script_name>.mor<function_name>.mThe directory is in the same location as
matlab_server.py
Environment Variables
MATLAB_PATH: Path to your MATLAB installationDefault:
/Applications/MATLAB_R2024a.appSet in Claude Desktop config or when running directly
Troubleshooting
MATLAB Engine Installation Fails
Verify MATLAB_PATH is correct
Try installing engine manually:
cd $MATLAB_PATH/extern/engines/python python setup.py install
Python Version Issues
Make sure you're using Python 3.11
Check with:
python --versionUse
uv python pin 3.11if needed
Script Execution Errors
Check the
matlab_scriptsdirectory existsVerify script syntax is valid
Look for error messages in MATLAB output
Updates and Maintenance
Keep your MATLAB installation updated
Update Python packages as needed:
uv pip install --upgrade mcp[cli]Check MATLAB engine compatibility when updating Python
This server cannot be deployed
Maintenance
Related MCP Connectors
Shared memory and actions for Claude, Kiro, OpenAI, Cursor, and other MCP-compatible AI clients.
Manage portable AI agent playbooks, Agent Skills, MCP configurations, personas, and memory.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Manage SRG+ hubs, channels, content, assets, users, and workspaces from any MCP-aware AI agent.
Related MCP Servers
- AlicenseBqualityFmaintenanceIntegrates MATLAB with AI to execute code, generate scripts from natural language, and access MATLAB documentation seamlessly.255Apache 2.0
- AlicenseNot gradedqualityDmaintenanceAllows execution of MATLAB code from Python using the MATLAB Engine API, enabling a shared MATLAB session across multiple requests for seamless integration with Claude Desktop.19MIT
- AlicenseNot gradedqualityDmaintenanceEnables interactive MATLAB development by allowing users to execute scripts and specific code sections, manage workspace variables, and capture generated plots. It integrates with the MATLAB Python Engine to provide persistent execution context for MCP-compatible clients.18BSD 3-Clause
- AlicenseAqualityAmaintenanceMCP server that connects any AI agent to MATLAB — execute code, async jobs, interactive Plotly plots, custom tools, and monitoring dashboard205MIT