by neuromechanist
Provides a Model Context Protocol server that enables executing full MATLAB scripts or individual sections, preserving workspace state, capturing plots, and interfacing with Cline or other MCP‑compatible clients.
Matlab MCP Tool delivers a server that bridges MATLAB with MCP‑compatible editors. It runs MATLAB code, maintains the interactive workspace across calls, and returns results—including generated figures—so that developers can work on MATLAB projects directly from their editor.
uv package manager.setup-matlab-mcp.sh script. This creates a virtual environment, installs the MATLAB Engine, and installs the matlab-mcp-server in development mode.mcp-config.json to the appropriate location (e.g., ~/.cursor/mcp.json).matlab-mcp-server (or python -m matlab_mcp.server).execute_script, execute_script_section, get_workspace.%% sections.matlab-mcp-server) and Python module entry point.matlab_output folder and their paths are included in the tool response.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.
Execute MATLAB Scripts
Section-based Execution
One-command installation with auto-detection:
./install-matlab-mcp.sh
That's it! The installer will:
/Volumes/S1/)Reduces installation time from 15+ minutes to ~2 minutes!
If you need custom configuration:
git clone [repository-url]
cd matlab-mcp-tools
# Only needed if MATLAB is in unusual location
export MATLAB_PATH=/path/to/your/matlab/installation
./install-matlab-mcp.sh
# Install uv using Homebrew
brew install uv
# OR install using pip
pip install uv
# For macOS (auto-detection searches common locations)
export MATLAB_PATH=/Applications/MATLAB_R2024b.app
# For Windows (use Git Bash terminal)
export MATLAB_PATH="C:/Program Files/MATLAB/R2024b"
./scripts/setup-matlab-mcp.sh
cp mcp-pip.json ~/.cursor/mcp.json
Test your installation:
./scripts/test-matlab-mcp.sh
Installation complete! The MATLAB MCP server is now ready to use with Cursor/Claude Code.
matlab-mcp-server
This is equivalent to running:
python -m matlab_mcp.server
You should see a startup message listing the available tools and confirming the server is running:
MATLAB MCP Server is running...
Available tools:
- execute_script: Execute MATLAB code or script file
- execute_script_section: Execute specific sections of a MATLAB script
- get_script_sections: Get information about script sections
- create_matlab_script: Create a new MATLAB script
- get_workspace: Get current MATLAB workspace variables
Use the tools with Cline or other MCP-compatible clients.
{
"mcpServers": {
"matlab": {
"command": "matlab-mcp-server",
"args": [],
"env": {
"MATLAB_PATH": "${MATLAB_PATH}",
"PATH": "${MATLAB_PATH}/bin:${PATH}"
},
"disabled": false,
"autoApprove": [
"list_tools",
"get_script_sections"
]
}
}
}
Hint: You can find the MATLAB engine installation path by running python -c "import matlab; print(matlab.__file__)".
execute_matlab_script
{
"script": "x = 1:10;\nplot(x, x.^2);",
"isFile": false
}
execute_matlab_section
{
"filePath": "analysis.m",
"sectionStart": 1,
"sectionEnd": 10
}
This example demonstrates running a complete MATLAB script that generates a plot:
% test_plot.m
x = linspace(0, 2*pi, 100);
y = sin(x);
% Create a figure with some styling
figure;
plot(x, y, 'LineWidth', 2);
title('Sine Wave');
xlabel('x');
ylabel('sin(x)');
grid on;
% Add some annotations
text(pi, 0, '\leftarrow \pi', 'FontSize', 12);
To execute this script using the MCP tool:
{
"script": "test_plot.m",
"isFile": true
}
The tool will execute the script and capture the generated plot, saving it to the output directory.
This example shows how to execute specific sections of a MATLAB script:
%% Section 1: Data Generation
% Generate sample data
x = linspace(0, 10, 100);
y = sin(x);
fprintf('Generated %d data points\n', length(x));
%% Section 2: Basic Statistics
% Calculate basic statistics
mean_y = mean(y);
std_y = std(y);
max_y = max(y);
min_y = min(y);
fprintf('Statistics:\n');
fprintf('Mean: %.4f\n', mean_y);
fprintf('Std Dev: %.4f\n', std_y);
fprintf('Max: %.4f\n', max_y);
fprintf('Min: %.4f\n', min_y);
%% Section 3: Plotting
% Create visualization
figure('Position', [100, 100, 800, 400]);
subplot(1, 2, 1);
plot(x, y, 'b-', 'LineWidth', 2);
title('Signal');
xlabel('x');
ylabel('y');
grid on;
subplot(1, 2, 2);
histogram(y, 20);
title('Distribution');
xlabel('Value');
ylabel('Count');
grid on;
sgtitle('Signal Analysis');
To execute specific sections:
{
"filePath": "section_test.m",
"sectionStart": 1,
"sectionEnd": 2
}
This will run sections 1 and 2, generating the data and calculating statistics. The output will include:
Generated 100 data points
Statistics:
Mean: 0.0000
Std Dev: 0.7071
Max: 1.0000
Min: -1.0000
The tool creates matlab_output and test_output directories to store:
The new install-matlab-mcp.sh installer handles most common issues automatically. If you encounter problems:
1. MATLAB not found:
export MATLAB_PATH=/your/matlab/path/Volumes/S1/Applications/)2. UV package manager issues:
curl -LsSf https://astral.sh/uv/install.sh | sh3. Python version compatibility:
4. Permission errors:
5. Configuration issues:
mcp-pip.json configurationuv is installed before running legacy scripts{
"command": "bash",
"args": ["-c", "source ~/.zshrc && /path/to/matlab-mcp-install/.venv/bin/matlab-mcp-server"]
}
.venv/bin/matlab-mcp-server --helpThis project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.