matlab
Matlab MCP Server in python
claude mcp add --transport stdio subspace-lab-matlab-mcp-server uvx matlab-mcp-server \ --env DYLD_LIBRARY_PATH="/Applications/MATLAB_R2025b.app/bin/maca64"
How to use
This MATLAB MCP server exposes a token-efficient interface to execute MATLAB commands in a persistent session, manage the workspace, handle figure I/O, and access MATLAB documentation and environment information through MCP clients. With the server running, you can send multi-operation requests to run code, fetch or modify variables, save or export figures as PNG/SVG/PDF, import/export data formats like CSV and JSON, and load or save MAT files. It also provides utilities to query MATLAB version and installed toolboxes, search for MATLAB functions, and locate toolbox paths, all through a single MCP connection. Typical clients include Claude Code, Claude Desktop, Cursor, VS Code (GitHub Copilot MCP), Codex, and other MCP-enabled tools, which package MATLAB operations into MCP commands to minimize round-trips.
To use it, configure an MCP client to connect to the matlab-mcp-server via uvx (as shown in the installation steps). Once connected, you can execute MATLAB code as if you were in a MATLAB session, query and set workspace variables, generate and save figures, and perform data I/O without switching between environments. The design emphasizes multi-operation commands to reduce API calls, so you can batch related actions (e.g., run a script that creates a figure and exports it) into a single MCP request when supported by your client.
How to install
Prerequisites:
- MATLAB installed on your system
- uv (the uv package manager) installed and available on your PATH
- A compatible MCP client setup (Claude Code/Desktop, Cursor, VS Code, Codex, etc.) if you plan to connect through a GUI client
Manual installation steps:
- Install the MATLAB engine for Python (if needed by your workflow) and ensure MATLAB can be invoked from the command line.
- Install the MCP server package on your client side:
- Using uv: uv pip install matlab-mcp-server
- Alternatively, install via your chosen MCP client’s recommended method for installing servers
- Configure the MCP client to run the server via uvx with the proper MATLAB library path:
- Example ( Claude Code / CLI ): uvx matlab-mcp-server
- Create or edit the mcp_config on your client to point to the server, including the MATLAB library path where MATLAB is installed. Example for Claude/CLI: { "mcpServers": { "matlab": { "command": "uvx", "args": ["matlab-mcp-server"], "env": { "DYLD_LIBRARY_PATH": "/Applications/MATLAB_R2025b.app/bin/maca64" } } } }
- Start your MCP client and verify the server is registered (e.g., list or info commands specific to your client).
- If you encounter library path issues, adjust LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (macOS) to point to your MATLAB installation's library directory as shown above.
Additional notes
Tips and common issues:
- Platform-specific environment variables: macOS users should typically set DYLD_LIBRARY_PATH to the MATLAB binary directory, while Linux users should use LD_LIBRARY_PATH. Windows generally does not require manual library path changes.
- Ensure MATLAB is properly installed and that the MATLAB engine API is accessible to the MCP server as needed by your client environment.
- If the MCP server fails to start, verify that the matlab-mcp-server package is installed and that uvx can resolve the command. Check that the environment variable paths match your MATLAB installation (e.g., /Applications/MATLAB_R2025b.app on macOS).
- When using GUI clients, you may need to restart the client after adding a new MCP server configuration. Look for the server icon or status indicators in the client UI to confirm connectivity.
- If you need to switch MATLAB paths, update the mcp_config.json or the client-specific configuration to reflect the new library path and restart the client.
- For batch operations, prefer commands that allow multi-step actions to minimize latency and API calls, leveraging the token-efficient design of MCP integration.
Related MCP Servers
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
mcp-yfinance
Real-time stock API with Python, MCP server example, yfinance stock analysis dashboard
cloudwatch-logs
MCP server from serkanh/cloudwatch-logs-mcp
MatlabMCP
MCP server to run MATLAB code from LLM via the Matlab Engine API.
servicenow-api
ServiceNow MCP Server and API Wrapper
the -company
TheMCPCompany: Creating General-purpose Agents with Task-specific Tools