Click on "Install 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 ToolRun the first section of analysis.m and show the resulting plot"
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 Tool
A Model Context Protocol (MCP) server that provides tools for developing and running MATLAB files. This tool integrates with Cline and other MCP-compatible clients to provide interactive MATLAB development capabilities.
Prerequisites
Python 3.10+
MATLAB with Python Engine installed
uv package manager (required)
Features
Execute MATLAB Scripts
Run complete MATLAB scripts
Execute individual script sections
Maintain workspace context between executions
Capture and display plots
Section-based Execution
Execute specific sections of MATLAB files
Support for cell mode (%% delimited sections)
Maintain workspace context between sections
Installation
Quick Start (Recommended)
One-command installation with auto-detection:
That's it! The installer will:
✅ Auto-detect MATLAB installations (including external volumes like
/Volumes/S1/)✅ Auto-install UV package manager if needed
✅ Create optimized virtual environment with MATLAB-compatible Python version
✅ Install all dependencies including MATLAB Python engine
✅ Generate MCP configuration ready for Cursor/Claude Code
✅ Verify installation works correctly
✅ Optionally configure Cursor automatically
Reduces installation time from 15+ minutes to ~2 minutes!
Advanced Installation
If you need custom configuration:
Clone this repository:
Set custom MATLAB path (optional - installer auto-detects):
Run installer:
Legacy Installation (Manual)
Install uv package manager:
Set MATLAB path environment variable:
Run legacy setup script:
Configure Cursor manually:
Testing Installation
Test your installation:
Installation complete! The MATLAB MCP server is now ready to use with Cursor/Claude Code.
Usage
Start the MCP server:
This is equivalent to running:
You should see a startup message listing the available tools and confirming the server is running:
Use the provided MCP configuration (see Installation) file to configure Cline/Cursor:
Hint: You can find the MATLAB engine installation path by running python -c "import matlab; print(matlab.__file__)".
Available Tools:
execute_matlab_script
{ "script": "x = 1:10;\nplot(x, x.^2);", "isFile": false }execute_matlab_section
{ "filePath": "analysis.m", "sectionStart": 1, "sectionEnd": 10 }
Examples
1. Simple Script Execution with Plot
This example demonstrates running a complete MATLAB script that generates a plot:
To execute this script using the MCP tool:
The tool will execute the script and capture the generated plot, saving it to the output directory.
2. Section-Based Execution
This example shows how to execute specific sections of a MATLAB script:
To execute specific sections:
This will run sections 1 and 2, generating the data and calculating statistics. The output will include:
Output Directory
The tool creates matlab_output and test_output directories to store:
Plot images generated during script execution
Other temporary files
Error Handling
Script execution errors are captured and returned with detailed error messages
Workspace state is preserved even after errors
Installation Troubleshooting
The new install-matlab-mcp.sh installer handles most common issues automatically. If you encounter problems:
Common Issues and Solutions
1. MATLAB not found:
The installer auto-detects MATLAB in common locations
If you have MATLAB in unusual location:
export MATLAB_PATH=/your/matlab/pathSupported locations include external volumes (e.g.,
/Volumes/S1/Applications/)
2. UV package manager issues:
The installer automatically installs UV if needed
For manual installation:
curl -LsSf https://astral.sh/uv/install.sh | sh
3. Python version compatibility:
Installer automatically selects MATLAB-compatible Python version
MATLAB R2024b: Python 3.11, R2024a: Python 3.10, R2023x: Python 3.9
4. Permission errors:
Run installer with appropriate permissions
On Windows: use Git Bash with Admin privileges
5. Configuration issues:
Use the auto-generated
mcp-pip.jsonconfigurationInstaller offers automatic Cursor configuration
Legacy Issues (if using manual installation)
Make sure
uvis installed before running legacy scriptsFor ENONET errors, ensure Python executable consistency:
MATLAB Python Engine compatibility: See MATLAB Engine docs
Still Having Issues?
Check installer output for specific error messages
Verify MATLAB license is valid and active
Test manually:
.venv/bin/matlab-mcp-server --helpOpen an issue with installer output if problem persists
Contributing
Fork the repository
Create a feature branch
Submit a pull request
License
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.