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:
Install MATLAB Engine The MATLAB Engine will be installed automatically when the server first runs, using the MATLAB installation specified in the
MATLAB_PATH
environment 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:
Add the MATLAB server configuration:
Make sure to:
Replace
/absolute/path/to/matlab-mcp
with the actual path to your project directoryVerify the
MATLAB_PATH
points 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_scripts
directoryFile names must be valid MATLAB identifiers
create_matlab_function
: Create a new MATLAB function fileFunctions are saved in the
matlab_scripts
directoryMust 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:
Example test script:
Script Storage
All MATLAB scripts and functions are saved in the
matlab_scripts
directoryThis directory is created automatically when the server starts
Files are named
<script_name>.m
or<function_name>.m
The directory is in the same location as
matlab_server.py
Environment Variables
MATLAB_PATH
: Path to your MATLAB installationDefault:
/Applications/MATLAB_R2024a.app
Set 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 --version
Use
uv python pin 3.11
if needed
Script Execution Errors
Check the
matlab_scripts
directory 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 installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Allows interaction with MATLAB by creating and executing scripts and functions through Claude or other MCP clients, supporting script management and execution result retrieval with environment configuration capabilities.
- Setup Requirements
- Installation
- Directory Structure
- Claude Desktop Integration
- Features
- Testing
- Script Storage
- Environment Variables
- Troubleshooting
- Updates and Maintenance
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityAllows Claude desktop app to execute terminal commands and edit files on your computer through MCP, with features including command execution, process management, and diff-based file editing.Last updated -2121,8194,578MIT License
Fused MCP Agentsofficial
-securityAlicense-qualityA Python-based MCP server that allows Claude and other LLMs to execute arbitrary Python code directly through your desktop Claude app, enabling data scientists to connect LLMs to APIs and executable code.Last updated -26MIT License- AsecurityAlicenseAqualityA utility tool that enables Claude Desktop to interact with external tools via the Model Context Protocol, providing features like email sending and simple calculations while simplifying the MCP setup process.Last updated -2013MIT License
- -securityAlicense-qualityAllows 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.Last updated -20MIT License