The MATLAB MCP Server enables integration between MATLAB and AI assistants, allowing you to execute MATLAB code, generate scripts from natural language, and access MATLAB documentation directly through your AI assistant conversations.
You can install the MATLAB MCP Server using npm:
npm install -g matlab-mcp-server
Alternatively, you can clone the repository and build it yourself:
git clone https://github.com/username/matlab-mcp-server.git
cd matlab-mcp-server
npm install
npm run build
To use the MATLAB MCP Server with Claude, you need to update the Claude desktop configuration file:
On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
Add the following configuration to the file:
{
"mcpServers": {
"matlab-server": {
"command": "node",
"args": ["/path/to/matlab-server/build/index.js"],
"env": {
"MATLAB_PATH": "/path/to/matlab/executable"
},
"disabled": false,
"autoApprove": []
}
}
}
Make sure to replace /path/to/matlab/executable
with the correct path to your MATLAB executable:
C:\\Program Files\\MATLAB\\R2023b\\bin\\matlab.exe
/Applications/MATLAB_R2023b.app/bin/matlab
/usr/local/MATLAB/R2023b/bin/matlab
You can access MATLAB documentation directly through the AI assistant using the URI format:
matlab://documentation/getting-started
To run MATLAB code through your AI assistant, you can use the execute_matlab_code
tool. This allows you to:
Example usage:
[Ask the AI to execute MATLAB code, such as plotting a function or analyzing data]
The generate_matlab_code
tool enables you to create MATLAB scripts by describing what you want to accomplish in plain language. Features include:
Example usage:
[Ask the AI to generate MATLAB code to perform a specific task, such as "Create a script to plot a sine wave with customizable frequency"]
Since MCP servers communicate over stdio, you can use the MCP Inspector for debugging:
npm run inspector
This will provide a URL to access debugging tools in your browser where you can monitor the server's communication and identify any issues.
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.