Back to MCP directory
publicPublicdnsLocal runtime

matlab-mcp-server

MATLAB与AI集成的MCP服务器,支持代码执行与生成

article

README

🚀 MATLAB MCP 服务器

这是一个功能强大的 MCP 服务器,它巧妙地将 MATLAB 与人工智能相结合。借助该服务器,您不仅能够执行 MATLAB 代码,还能依据自然语言描述生成 MATLAB 脚本,甚至能直接通过您的 AI 助手访问 MATLAB 文档。

✨ 主要特性

资源

  • 可通过 matlab://documentation/getting-started URI 访问 MATLAB 文档。
  • 提供了详细的入门指南,其中包含示例和使用说明。

工具

  • execute_matlab_code:执行 MATLAB 代码并获取结果。

    • 能够运行任何 MATLAB 命令或脚本。
    • 支持可选保存脚本,方便您将来参考。
    • 可直接在对话中查看输出。
  • generate_matlab_code:从自然语言生成 MATLAB 代码。

    • 您只需使用自然语言描述要完成的任务。
    • 就能在响应中获得可执行的 MATLAB 代码。
    • 同样支持可选保存生成的脚本。

📦 安装指南

安装要求

  • 系统上已安装 MATLAB。
  • Node.js (v14 或更高版本)。

安装步骤

1. 安装包

npm install -g matlab-mcp-server

或者,您也可以克隆仓库并自行构建:

git clone https://github.com/username/matlab-mcp-server.git
cd matlab-mcp-server
npm install
npm run build

2. 配置 cline 使用服务器

要与 cline 一起使用,请添加服务器配置:

  • 在 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": []
    }
  }
}

请将 /path/to/matlab/executable 替换为您 MATLAB 可执行文件的路径:

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

调试

由于 MCP 服务器通过 stdio 通信,调试可能具有挑战性。我们推荐使用 MCP Inspector,该工具作为包脚本可用:

npm run inspector

Inspector 将提供访问浏览器中的调试工具的 URL。

🔧 技术细节

开发步骤

  • 安装依赖:
npm install
  • 构建服务器:
npm run build
  • 带自动重建开发:
npm run watch
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client