The MATLAB MCP Server is a tool that integrates MATLAB with AI assistants, allowing you to execute MATLAB code, generate scripts from natural language descriptions, and access MATLAB documentation directly through your AI assistant.
For Claude Desktop users, install automatically via Smithery:
npx -y @smithery/cli install @WilliamCloudQi/matlab-mcp-server --client claude
Install globally via npm:
npm install -g matlab-mcp-server
Or clone and build the repository:
git clone https://github.com/username/matlab-mcp-server.git
cd matlab-mcp-server
npm install
npm run build
Add the server configuration to Claude Desktop's config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"matlab-server": {
"command": "node",
"args": ["/path/to/matlab-server/build/index.js"],
"env": {
"MATLAB_PATH": "/path/to/matlab/executable"
},
"disabled": false,
"autoApprove": []
}
}
}
Replace /path/to/matlab/executable with your actual MATLAB executable path:
C:\\Program Files\\MATLAB\\R2023b\\bin\\matlab.exe/Applications/MATLAB_R2023b.app/bin/matlab/usr/local/MATLAB/R2023b/bin/matlabTo run MATLAB code through your AI assistant:
execute_matlab_code toolExample prompt:
Please execute this MATLAB code to create a simple plot:
x = linspace(0, 2*pi, 100);
y = sin(x);
plot(x, y);
title('Sine Wave');
To generate MATLAB code based on a description:
generate_matlab_code toolExample prompt:
Generate MATLAB code to create a 3D surface plot of a sine function in x and cosine in y
You can access MATLAB documentation through the matlab://documentation/getting-started URI, which provides helpful resources for using MATLAB effectively.
If you encounter issues, you can run the MCP Inspector for debugging:
npm run inspector
This will provide a URL to access debugging tools in your browser.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "matlab-server" '{"command":"node","args":["/path/to/matlab-server/build/index.js"],"env":{"MATLAB_PATH":"/path/to/matlab/executable"},"disabled":false,"autoApprove":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"matlab-server": {
"command": "node",
"args": [
"/path/to/matlab-server/build/index.js"
],
"env": {
"MATLAB_PATH": "/path/to/matlab/executable"
},
"disabled": false,
"autoApprove": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"matlab-server": {
"command": "node",
"args": [
"/path/to/matlab-server/build/index.js"
],
"env": {
"MATLAB_PATH": "/path/to/matlab/executable"
},
"disabled": false,
"autoApprove": []
}
}
}
3. Restart Claude Desktop for the changes to take effect