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
31 stars

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.

Features

MATLAB Integration

  • Execute MATLAB code and view results directly in your conversation
  • Generate MATLAB code from natural language descriptions
  • Access MATLAB documentation seamlessly

Available Tools

  • execute_matlab_code: Run MATLAB commands and scripts with results displayed in your conversation
  • generate_matlab_code: Convert natural language descriptions into executable MATLAB code

Requirements

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

Installation

Method 1: Install via Smithery

For Claude Desktop users, install automatically via Smithery:

npx -y @smithery/cli install @WilliamCloudQi/matlab-mcp-server --client claude

Method 2: Manual Installation

Step 1: Install the package

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

Step 2: Configure Claude to use the server

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:

  • 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

Usage

Executing MATLAB Code

To run MATLAB code through your AI assistant:

  1. Ask the assistant to execute MATLAB code
  2. The assistant will use the execute_matlab_code tool
  3. View the results directly in your conversation

Example 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');

Generating MATLAB Code from Natural Language

To generate MATLAB code based on a description:

  1. Describe what you want to accomplish in plain language
  2. The assistant will use the generate_matlab_code tool
  3. Receive executable MATLAB code in response

Example prompt:

Generate MATLAB code to create a 3D surface plot of a sine function in x and cosine in y

Accessing MATLAB Documentation

You can access MATLAB documentation through the matlab://documentation/getting-started URI, which provides helpful resources for using MATLAB effectively.

Troubleshooting

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.

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