MATLAB MCP Server
MATLAB MCP 集成
这是 MATLAB 模型上下文协议 (MCP) 服务器的实现。它允许 MCP 客户端(例如 LLM 代理或 Claude Desktop)使用 Python 版 MATLAB 引擎 API 与共享的 MATLAB 会话进行交互。
特征
**执行 MATLAB 代码:**通过
runMatlabCode工具运行任意 MATLAB 代码片段。**检索变量:**使用
getVariable工具从 MATLAB 工作区获取变量的值。**结构化通信:**工具以结构化 JSON 的形式返回结果和错误,以便客户端更轻松地以编程方式使用。
非阻塞执行: MATLAB 引擎调用使用
asyncio.to_thread异步运行,以防止阻塞服务器。**标准日志记录:**使用 Python 的标准
logging模块,输出到stderr以便在客户端日志中可见。**共享会话:**连接到现有的共享 MATLAB 会话。
待办事项:
添加
setVariable工具以将数据写入 MATLAB 工作区。添加
runScript工具直接执行.m文件。添加工作区管理工具(例如
clearWorkspace、getWorkspaceVariables)。扩展
matlab_to_python助手来处理更复杂的数据类型(结构、单元格数组、对象)。添加与 Simulink 模型交互的支持。
Related MCP server: MATLAB MCP Server
要求
Python 3.12 或更高版本
安装了 MATLAB Engine API for Python 的 MATLAB(建议使用 R2023a 或更高版本- 检查 MATLAB Engine API for Python 兼容性)。
numpyPython 包。
安装
克隆此存储库:
git clone https://github.com/jigarbhoye04/MatlabMCP.git cd MatlabMCP设置Python虚拟环境(推荐):
# Install uv if you haven't already: https://github.com/astral-sh/uv uv init uv venv source .venv/bin/activate # On Windows use: .venv\Scripts\activate安装依赖项:
uv pip sync确保已安装 MATLAB,并已为您的 Python 环境配置适用于 Python 的 MATLAB 引擎 API。请参阅MATLAB 文档。
**启动 MATLAB 并共享其引擎:**在 MATLAB 命令窗口中运行以下命令:
matlab.engine.shareEngine您可以通过在 MATLAB 中运行
matlab.engine.isEngineShared来验证它是否已共享(它应该返回true或1)。MCP 服务器需要此共享引擎才能连接。
配置(适用于 Claude Desktop)
要将此服务器与 Claude Desktop 一起使用:
转到 Claude Desktop -> 设置 -> 开发人员 -> 编辑配置。
这将打开
claude_desktop_config.json。添加或修改mcpServers部分以包含MatlabMCP配置:{ "mcpServers": { "MatlabMCP": { "command": "C:\\Users\\username\\.local\\bin\\uv.exe", // Path to your uv executable "args": [ "--directory", "C:\\Users\\username\\Desktop\\MatlabMCP\\", // ABSOLUTE path to the cloned repository directory "run", "main.py" ] // Optional: Add environment variables if needed // "env": { // "MY_VAR": "value" // } } // Add other MCP servers here if you have them } }重要提示:将
C:\\Users\\username\\...路径替换为系统的正确绝对路径。保存文件并重新启动 Claude Desktop 。
**日志记录:**服务器日志(来自 Python 的
logging模块)将出现在 Claude Desktop 的 MCP 日志文件中(可通过 macOS 上的tail -f ~/Library/Logs/Claude/mcp-server-MatlabMCP.log访问或在 Windows 上检查%APPDATA%\Claude\logs\访问)。
发展
项目结构:
MatlabMCP/
├── .venv/ # Virtual environment created by uv
├── Docs/
│ └── Images/
│ └── Updates.md # Documentation for updates and changes
├── main.py # The MCP server script
├── pyproject.toml # Project metadata and dependencies
├── README.md # This file
└── uv.lock # Lock file for dependencies文档
查看更新以获取有关服务器功能、使用和开发说明的详细文档。
贡献
欢迎贡献代码!如果您有任何建议或改进,欢迎随时创建 issue 或提交 Pull 请求。
让我们一起让它变得更好!
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Build Apps and run code in 30 languages — sandboxed, with persistent sessions for agent loops.
Share context and questions between Claude instances — VS Code, claude.ai web, and mobile.
Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).
Hosted Amazon Seller Central and Amazon Ads MCP server for Claude, ChatGPT, Cursor, and agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAllows interaction with MATLAB by creating and executing scripts and functions through Claude or other MCP clients, supporting script management and execution result retrieval with environment configuration capabilities.39
- AlicenseBqualityFmaintenanceIntegrates MATLAB with AI to execute code, generate scripts from natural language, and access MATLAB documentation seamlessly.255Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables interactive MATLAB development by allowing users to execute scripts and specific code sections, manage workspace variables, and capture generated plots. It integrates with the MATLAB Python Engine to provide persistent execution context for MCP-compatible clients.18BSD 3-Clause
- AlicenseAqualityAmaintenanceMCP server that connects any AI agent to MATLAB — execute code, async jobs, interactive Plotly plots, custom tools, and monitoring dashboard205MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jigarbhoye04/MatlabMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server