MATLAB MCP server

Integrates with MATLAB to execute code, generate scripts from natural language, and access documentation, enabling complex mathematical operations and data analysis using MATLAB's toolsets.
Back to servers
Provider
William Cloud Qi
Release date
Feb 27, 2025
Language
TypeScript
Stats
24 stars

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.

Requirements

  • MATLAB installed on your system
  • Node.js (v14 or higher)

Installation

Installing the Package

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

Configuring Claude to Use the Server

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:

  • Windows: Usually C:\\Program Files\\MATLAB\\R2023b\\bin\\matlab.exe
  • macOS: Usually /Applications/MATLAB_R2023b.app/bin/matlab
  • Linux: Usually /usr/local/MATLAB/R2023b/bin/matlab

Using the MATLAB MCP Server

Accessing Documentation

You can access MATLAB documentation directly through the AI assistant using the URI format:

matlab://documentation/getting-started

Executing MATLAB Code

To run MATLAB code through your AI assistant, you can use the execute_matlab_code tool. This allows you to:

  • Run any MATLAB commands or scripts
  • Save scripts for future reference
  • View output directly in your conversation

Example usage:

[Ask the AI to execute MATLAB code, such as plotting a function or analyzing data]

Generating MATLAB Code from Natural Language

The generate_matlab_code tool enables you to create MATLAB scripts by describing what you want to accomplish in plain language. Features include:

  • Describing your task in natural language
  • Getting executable MATLAB code in response
  • Saving generated scripts for later use

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"]

Troubleshooting

Debugging the Server

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.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later