MATLAB
Execute MATLAB scripts and functions via MCP clients. Requires a local MATLAB installation.
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
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.json
- Add 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 directory - Verify the
MATLAB_PATHpoints to your MATLAB installation - Use absolute paths (not relative)
Features
The server provides several tools:
-
create_matlab_script: Create a new MATLAB script file- Scripts are saved in the
matlab_scriptsdirectory - File names must be valid MATLAB identifiers
- Scripts are saved in the
-
create_matlab_function: Create a new MATLAB function file- Functions are saved in the
matlab_scriptsdirectory - Must include valid function definition
- Functions are saved in the
-
execute_matlab_script: Run a MATLAB script and get results- Returns output text, generated figures, and workspace variables
- Can pass arguments to scripts
-
call_matlab_function: Call a MATLAB function with arguments- Returns 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.py
Example 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_scriptsdirectory - This directory is created automatically when the server starts
- Files are named
<script_name>.mor<function_name>.m - The directory is in the same location as
matlab_server.py
Environment Variables
MATLAB_PATH: Path to your MATLAB installation- Default:
/Applications/MATLAB_R2024a.app - Set in Claude Desktop config or when running directly
- Default:
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 --version - Use
uv python pin 3.11if needed
-
Script Execution Errors
- Check the
matlab_scriptsdirectory exists - Verify script syntax is valid
- Look for error messages in MATLAB output
- Check the
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
Máy chủ liên quan
Scout Monitoring MCP
nhà tài trợPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
nhà tài trợAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
GenCodeDoc
Intelligent code versioning (snapshots) and automatic documentation generator. With CLI, REST API, and MCP support.
SVG to PNG MCP Server
A server that converts SVG code to PNG images using the cairosvg library.
MCP Everything
A demonstration server for the Model Context Protocol (MCP) showcasing various features like tools, resources, and prompts in TypeScript and Python.
Next.js MCP Server
A Next.js-based MCP server with OAuth 2.1 authentication support using Google as the default provider. Requires a PostgreSQL database and optionally Redis for SSE transport.
Claude KVM
🤖 ⚡️ MCP server ( MacOS) — control remote desktops via VNC
Sentinel Signal MCP
Agent tools via MCP for workflow scoring, limits/usage, and feedback (trial key supported)
Rug-Check-MCP
Detects potential risks in Solana meme tokens to help avoid rug pulls and unsafe projects.
MCP Server Starter Template
A starter template for building Model Context Protocol (MCP) servers, designed for UI libraries and component registries.
Unity MCP
An MCP server and plugin for connecting the Unity Editor and games to MCP clients like Claude Desktop.
Remote MCP Server (Authless)
An example of a remote MCP server deployable on Cloudflare Workers without authentication.