|
| 1 | +# MATLAB MCP Core Server |
| 2 | + |
| 3 | +Run MATLAB® using AI applications. The MATLAB MCP Core Server allows your AI applications to: |
| 4 | + |
| 5 | +- Start and quit MATLAB. |
| 6 | +- Write and run MATLAB code. |
| 7 | +- Assess your MATLAB code for style and correctness. |
| 8 | + |
| 9 | +## Table of Contents |
| 10 | + - [Setup](#setup) |
| 11 | + - [Claude Code](#claude-code) |
| 12 | + - [Claude Desktop](#claude-desktop) |
| 13 | + - [GitHub Copilot in Visual Studio Code](#github-copilot-in-visual-studio-code) |
| 14 | + - [Arguments](#arguments) |
| 15 | + - [Tools](#tools) |
| 16 | + - [Data Collection](#data-collection) |
| 17 | + - [Disclaimer](#disclaimer) |
| 18 | + |
| 19 | +## Setup |
| 20 | + |
| 21 | +1. Install [MATLAB (MathWorks)](https://www.mathworks.com/help/install/ug/install-products-with-internet-connection.html) 2020b or later and add it to the system PATH. |
| 22 | +2. Download the [Latest Release](https://github.com/matlab/matlab-mcp-core-server/releases/latest) from GitHub®. Alternatively, you can install [Go](https://go.dev/doc/install) and build the binary from source using `go install github.com/matlab/matlab-mcp-core-server/cmd/matlab-mcp-core-server`. |
| 23 | +3. Add the MATLAB MCP Core Server to your AI application. You can find instructions for adding MCP servers in the documentation of your AI application. For example instructions on using Claude Code®, Claude Desktop®, and GitHub Copilot in Visual Studio® Code, see below. Note that you can customize the server by specifying optional [arguments](#arguments). |
| 24 | + |
| 25 | +#### Claude Code |
| 26 | + |
| 27 | +In your terminal, run the following, remembering to insert the full path to the server binary you acquired in the setup: |
| 28 | +```sh |
| 29 | +claude mcp add --transport stdio matlab /fullpath/to/matlab-mcp-core-server-binary [arguments...] |
| 30 | +``` |
| 31 | +You can customize the server by specifying [arguments](#arguments): |
| 32 | +```sh |
| 33 | +claude mcp add --transport stdio matlab /fullpath/to/matlab-mcp-core-server-binary --initial-working-folder=/home/username/myproject |
| 34 | +``` |
| 35 | + |
| 36 | +For details on adding MCP servers in Claude Code, see [Add a local stdio server (Claude Code)](https://docs.claude.com/en/docs/claude-code/mcp#option-3%3A-add-a-local-stdio-server). To remove the server later, run: |
| 37 | +```sh |
| 38 | +claude mcp remove matlab |
| 39 | +``` |
| 40 | + |
| 41 | +#### Claude Desktop |
| 42 | + |
| 43 | +Follow the instructions on the page [Connect to local MCP servers (MCP)](https://modelcontextprotocol.io/docs/develop/connect-local-servers) to install Node.js and the Filesystem Server. In your Claude Desktop configuration file, you need to add the configuration for the MATLAB MCP Core Server as well as the Filesystem Server. You can use the combined JSON below. In the Filesystem `args`, remember to specify which paths the server can access. In the MATLAB `args`, remember to insert the full path to the server binary you acquired, as well as any other arguments: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "mcpServers": { |
| 48 | + "filesystem": { |
| 49 | + "command": "npx", |
| 50 | + "args": [ |
| 51 | + "-y", |
| 52 | + "@modelcontextprotocol/server-filesystem", |
| 53 | + "C:\\Users\\username" |
| 54 | + ] |
| 55 | + }, |
| 56 | + "matlab": { |
| 57 | + "command": "fullpath\\to\\matlab-mcp-core-server-binary", |
| 58 | + "args": [ |
| 59 | + "--initial-working-folder=C:\\Users\\username\\Documents" |
| 60 | + ] |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | +After saving the configuration file, quit and restart Claude Desktop. |
| 66 | + |
| 67 | +#### GitHub Copilot in Visual Studio Code |
| 68 | + |
| 69 | +VS Code provides different methods to [Add an MCP Server (VS Code)](https://code.visualstudio.com/docs/copilot/customization/mcp-servers?wt.md_id=AZ-MVP-5004796#_add-an-mcp-server). MathWorks recommends you follow the steps in the section **"Add an MCP server to a workspace `mcp.json` file"**. In your `mcp.json` configuration file, add the following, remembering to insert the full path to the server binary you acquired in the setup, as well as any arguments: |
| 70 | +```json |
| 71 | +{ |
| 72 | + "servers": { |
| 73 | + "matlab": { |
| 74 | + "type": "stdio", |
| 75 | + "command": "/fullpath/to/matlab-mcp-core-server-binary", |
| 76 | + "args": [] |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## Arguments |
| 83 | + |
| 84 | +Customize the behavior of the server by providing arguments in the `args` array when configuring your AI application. |
| 85 | + |
| 86 | +| Argument | Description | Example | |
| 87 | +| ------------- | ------------- | ------------- | |
| 88 | +| matlab-root | Full path specifying which MATLAB to start. Do not include `/bin` in the path. By default, the server tries to find the first MATLAB on the system PATH. | `"--matlab-root=/home/usr/MATLAB/R2025a"` | |
| 89 | +| initial-working-folder | Specify the folder where MATLAB starts and where the server generates any MATLAB scripts. If you do not provide the argument, MATLAB starts in the folder specified by the last entry in your list of [Roots (MCP)](https://modelcontextprotocol.io/specification/2025-06-18/client/roots). If you do not specify a root, MATLAB starts in these locations: <br><br> <ul><li>Linux: `/home/username` </li><li> Windows: `C:\Users\username\Documents`</li><li>Mac: `/Users/username/Documents`</li></ul> | `"--initial-working-folder=C:\\Users\\name\\MyProject"` | |
| 90 | +| disable-telemetry | To disable anonymized data collection, set this argument to `true`. For details, see [Data Collection](#data-collection). | `"--disable-telemetry=true"` | |
| 91 | + |
| 92 | +## Tools |
| 93 | + |
| 94 | +1. `detect_matlab_toolboxes` |
| 95 | + - Lists installed MATLAB toolboxes with version information. |
| 96 | + |
| 97 | +2. `check_matlab_code` |
| 98 | + - Performs static code analysis on a MATLAB script. Returns warnings about coding style, potential errors, deprecated functions, performance issues, and best practice violations. This is a non-destructive, read-only operation that helps identify code quality issues without executing the script. |
| 99 | + - Inputs: |
| 100 | + - `script_path` (string): Absolute path to the MATLAB script file to analyze. Must be a `.m` file within an allowed directory. The file is not modified during analysis. Example: `C:\Users\username\matlab\myFunction.m` or `/home/user/scripts/analysis.m`. |
| 101 | + |
| 102 | +3. `evaluate_matlab_code` |
| 103 | + - Evaluates a string of MATLAB code and returns the output. |
| 104 | + - Inputs: |
| 105 | + - `code` (string): MATLAB code to evaluate. |
| 106 | + - `project_path` (string): Absolute path to an allowed project directory. MATLAB sets this directory as the current working folder. Example: `C:\Users\username\matlab-project` or `/home/user/research`. |
| 107 | + |
| 108 | +4. `run_matlab_file` |
| 109 | + - Executes a MATLAB script and returns the output. The script must be a valid `.m file`. |
| 110 | + - Inputs: |
| 111 | + - `script_path` (string): Absolute path to the MATLAB script file to execute. Must be a valid `.m` file within an allowed directory. Example: `C:\Users\username\projects\analysis.m` or `/home/user/matlab/simulation.m`. |
| 112 | + |
| 113 | +5. `run_matlab_test_file` |
| 114 | + - Executes a MATLAB test script and returns comprehensive test results. Designed specifically for MATLAB unit test files that follow MATLAB testing framework conventions. |
| 115 | + - Inputs: |
| 116 | + - `script_path` (string): Absolute path to the MATLAB test script file. Must be a valid `.m` file containing MATLAB unit tests, within an allowed directory. Example: `C:\Users\username\tests\testMyFunction.m` or `/home/user/matlab/tests/test_analysis.m`. |
| 117 | + |
| 118 | +## Data Collection |
| 119 | + |
| 120 | +The MATLAB MCP Core Server may collect fully anonymized information about your usage of the server and send it to MathWorks. This data collection helps MathWorks improve products and is on by default. To opt out of data collection, set the argument `--disable-telemetry` to `true`. |
| 121 | + |
| 122 | +## Disclaimer |
| 123 | + |
| 124 | +The MATLAB MCP Core Server is provided "as is" without warranties of any kind, expressed or implied. By using this server, you acknowledge and accept that you are solely responsible for any actions taken and any consequences arising from its use. It is your responsibility to thoroughly review and validate all tool calls before execution. The developers and providers of this server disclaim any liability for loss, damage, or injury resulting from its use. |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +Copyright 2025 The MathWorks, Inc. |
| 129 | + |
| 130 | +---- |
0 commit comments