Content
MATLAB + Simulink + Claude Desktop (MCP) Setup Guide
Connecting a local MATLAB R2024b installation to Claude Desktop using the official MathWorks MATLAB MCP Server — with a full debugging log and a working example: an AI-generated Simulink counter model.
Overview
System Requirements
Available Tools
Installation (Claude Desktop, Windows)
1. Download the Correct Asset
2. Install the Filesystem Extension
3. Install the MATLAB MCP Server Bundle
4. Configure the MATLAB Extension
5. Set Tool Permissions
Debugging Log: Filesystem Extension Failure
Verification Tests
Example: Building a Simulink Counter Model
Lessons Learned
References
Overview
This repository documents the complete process of connecting MATLAB R2024b to Claude Desktop via the official MATLAB MCP Server (Model Context Protocol), including every error encountered and how it was diagnosed and resolved.
The integration allows Claude to:
Detect the local MATLAB installation and its toolboxes
Statically analyze (lint) MATLAB .m scripts
Evaluate MATLAB code and execute scripts directly
Run MATLAB unit test files
Programmatically build and run Simulink models via the MATLAB Engine
As a hands-on validation, this guide walks through generating a simple Simulink counter model (1 → 255, wrapping via uint8 overflow) entirely through natural-language prompts.
Only use the official, MathWorks-maintained repository:
text
https://github.com/matlab/matlab-mcp-server
Every release asset there ships with a published SHA-256 checksum. Verify it before running anything:
powershell
Get-FileHash "C:\path\to\downloaded-file" -Algorithm SHA256
System Requirements
Requirement Detail
OS Windows 10/11 (Linux/macOS also supported by the server)
MATLAB R2021a or later — supports releases from the past five years
MATLAB install path used here C:\Program Files\MATLAB\R2024b (added to system PATH)
Claude Desktop Installed and signed in
Node.js Required for the companion Filesystem extension
Available Tools
The official MATLAB MCP Server exposes five tools:
Tool Description Type
detect_matlab_toolboxes Lists installed MATLAB version and toolboxes 🟢 Read-only
check_matlab_code Static analysis / linting of a .m file 🟢 Read-only
evaluate_matlab_code Executes a string of MATLAB code 🔴 Write/Execute
run_matlab_file Executes a .m script 🔴 Write/Execute
run_matlab_test_file Executes MATLAB unit tests 🔴 Write/Execute
Installation (Claude Desktop, Windows)
1. Download the Correct Asset
The official releases page (matlab/matlab-mcp-server/releases/latest) publishes two relevant Windows assets:
File Purpose
matlab-mcp-server-windows-x64.exe Raw binary for manual JSON config (VS Code, Codex, Claude Code CLI)
matlab-mcp-server.mcpb Packaged bundle required for one-click install into Claude Desktop
Important: A .exe cannot simply be renamed to .mcpb. A .mcpb is a structured bundle (manifest + binary + metadata), not a renamed executable. Download the correct asset directly.
2. Install the Filesystem Extension
Claude Desktop → Settings → Extensions → Browse extensions
Search for Filesystem (by Anthropic) → Install
Grant access to your target project folder
Enable the extension
3. Install the MATLAB MCP Server Bundle
Double-clicking the .exe file may not trigger Claude Desktop's installer as expected — instead it can launch a raw console window showing normal (but easy to misread) JSON-RPC output:
json
{"jsonrpc":"2.0","method":"notifications/resources/list_changed","params":{}}
{"jsonrpc":"2.0","method":"notifications/tools/list_changed","params":{}}
Use the reliable install path instead:
Claude Desktop → File → Settings → Extensions → Advanced Settings → Install Extension
If the file picker only shows an "Extension" filter and hides .mcpb, switch the filter dropdown to "All Files"
Or, more reliably: drag-and-drop the .mcpb file directly onto the Claude Desktop Extensions window
4. Configure the MATLAB Extension
Set the following arguments under Settings → Extensions → MATLAB → Configure:
Argument Value Used
matlab-root C:\Program Files\MATLAB\R2024b
matlab-display-mode desktop (visible during initial testing)
initial-working-folder C:\Users\<you>\Desktop\MATLAB_Claude
initialize-matlab-on-startup default (false)
disable-telemetry optional
5. Set Tool Permissions
Category Setting Rationale
Read-only (Check MATLAB Code, Detect MATLAB Toolboxes) Always allow Non-destructive, no code execution
Write/Execute (Evaluate MATLAB Code, Run MATLAB File, Run MATLAB test file) Always ask Executes arbitrary code with user privileges — MathWorks explicitly recommends human-in-the-loop review before every call
Debugging Log: Filesystem Extension Failure
While the MATLAB extension connected cleanly, the Filesystem extension repeatedly failed with Server disconnected, reproducing identically across multiple restart attempts.
Symptom 1 — Immediate Disconnect After Initialize
text
[Filesystem] [info] Using built-in Node.js for MCP server: Filesystem
[Filesystem] [info] Era probe verdict: legacy (sibling did not complete the exchange)
[Filesystem] [info] Server started and connected successfully
[Filesystem] [info] Message from client: method="initialize" id=0
[Filesystem] [info] Server transport closed
[Filesystem] [info] Server transport closed unexpectedly, this is likely due to
the process exiting early.
[Filesystem] [error] Server disconnected.
Diagnosis: The server accepted the MCP handshake but crashed within seconds of the first real initialize message, every time.
The "Era probe verdict: legacy" line indicated a runtime compatibility probe was failing and falling back to a legacy execution path.
Ruled-Out Causes
❌ Node.js not installed — confirmed present via node -v → v24.19.0
❌ winget package manager issue — unrelated (Node.js was already installed)
❌ Built-in vs. system Node.js toggle — no change in behavior either way
Symptom 2 — Root Cause Revealed
After forcing system Node.js and restarting, the log surfaced the actual exception:
text
[Filesystem] [info] Using MCP server command: C:\Program Files\nodejs\node.exe
[Filesystem] [info] Server started and connected successfully
[Filesystem] [info] Message from client: method="initialize" id=0
Warning: Cannot access directory C:\WINDOWS\System32\"C:\Users\Ismail\Desktop\MATLAB_Claude, skipping
Error: None of the specified directories are accessible
[Filesystem] [info] Server transport closed
[Filesystem] [error] Server disconnected.
Root cause: The configured allowed-directory argument was corrupted in two ways:
It was concatenated with the process's working directory (C:\WINDOWS\System32\) instead of being passed as a clean, standalone absolute path.
A stray double-quote character (") was embedded mid-string, right before C:\Users.
Since no valid directory could be resolved, the server correctly refused to start.
✅ Fix Applied
Removed the corrupted directory entry entirely rather than editing it in place
Re-added the folder using the extension's folder picker (avoiding manual typing/pasted quotes)
Verified the target folder existed on disk beforehand
Fully restarted via system tray → Quit → relaunch
Result: Clean startup, no further disconnects, green "connected" status in the Developer panel.
Verification Tests
# Prompt Tool Exercised Approval Needed?
1 "Detect my installed MATLAB toolboxes and tell me the version." detect_matlab_toolboxes No (read-only)
2 "List the files in my MATLAB_Claude folder on the desktop." Filesystem read No
3 "Use MATLAB to evaluate this code: disp('Hello from Claude')" evaluate_matlab_code Yes (write/execute)
Example: Building a Simulink Counter Model
As an end-to-end test combining code generation, the Simulink API, and the write-tool approval workflow, the following prompt generates a counter model that increments from 1 to 255 and wraps automatically (native behavior of an 8-bit unsigned integer):
"Using MATLAB, write a script that programmatically creates a new Simulink model containing a counter that increments from 1 to 255 and then wraps back to 1. Use a Unit Delay or Counter Limited block, an appropriate data type (uint8, since it naturally wraps at 255), and a Scope to visualize the output. Save the model in my MATLAB_Claude folder, then open it so I can see it."
Why this prompt works:
"Programmatically creates" → directs Claude to generate MATLAB code (new_system, add_block, add_line) rather than describing manual GUI steps
Specifying uint8 → an 8-bit unsigned integer naturally overflows and wraps at 255, matching the requirement without extra reset logic
Naming the folder → ties the operation to the verified Filesystem extension
"Open it so I can see it" → confirms the result visually via the MATLAB desktop window
Representative generated code:
matlab
new_system('CounterModel');
open_system('CounterModel');
add_block('simulink/Sources/Counter Limited', 'CounterModel/Counter');
set_param('CounterModel/Counter', 'uplimit', '255');
add_block('simulink/Sinks/Scope', 'CounterModel/Scope');
add_line('CounterModel', 'Counter/1', 'Scope/1');
save_system('CounterModel', ...
'C:\Users\Ismail\Desktop\MATLAB_Claude\CounterModel.slx');
⚠️ Since this uses evaluate_matlab_code (a write/execute tool), an approval prompt appears before running.
Always review generated code line-by-line before approving — per MathWorks' own guidance: "thoroughly review and validate all tool calls before you run them... always keep a human in the loop for important actions."
Optional — run the simulation to see it progress live:
"Also configure the simulation to run for 300 steps at a fixed step size of 1, then run the simulation so I can see the counter progressing in the scope."
Lessons Learned
Verify sources. A convincing but fake PDF pointed to an unverifiable third-party executable. The legitimate server is only distributed via github.com/matlab/matlab-mcp-server, with SHA-256 checksums for every asset.
.mcpb and .exe are not interchangeable — only the .mcpb bundle installs cleanly into Claude Desktop's Extensions UI.
File-picker filters in Claude Desktop's "Install Extension" dialog can hide valid files — drag-and-drop is the more robust installation method.
Node.js detection in Claude Desktop's settings can lag behind an actual system installation until a full application (or system) restart.
Read the raw MCP server logs.
The real root cause of the Filesystem failure was a corrupted, concatenated directory path — invisible from the UI, but obvious once the raw log was inspected (Developer → View Logs).
Tier your tool permissions deliberately.
Allow read-only tools freely; require explicit approval for anything capable of executing code on the host machine.
References
Official server: matlab/matlab-mcp-server
MATLAB Agentic Toolkit
Simulink Agentic Toolkit
Model Context Protocol specification
License
This guide and example code are shared under the MIT License.
The MATLAB MCP Server itself is subject to the MathWorks Software License Agreement.
Connection Info
You Might Also Like
No recommendations available