MATLAB MCP Integration logo

MATLAB MCP Integration

by jigarbhoye04

This is an implementation of a Model Context Protocol (MCP) server for MATLAB. It allows MCP clients to interact with a shared MATLAB session using the MATLAB Engine API for Python.

View on GitHub

Last updated: N/A

What is MATLAB MCP Integration?

The MATLAB MCP Integration is a server that enables communication between MCP clients (like LLM agents or Claude Desktop) and a shared MATLAB session. It leverages the MATLAB Engine API for Python to execute MATLAB code and retrieve variables.

How to use MATLAB MCP Integration?

  1. Clone the repository. 2. Set up a Python virtual environment. 3. Install dependencies. 4. Configure MATLAB Engine API for Python. 5. Start MATLAB and share its engine using matlab.engine.shareEngine. 6. Configure your MCP client (e.g., Claude Desktop) with the server's command and arguments, pointing to the main.py script.

Key features of MATLAB MCP Integration

  • Execute MATLAB Code

  • Retrieve Variables

  • Structured Communication

  • Non-Blocking Execution

  • Standard Logging

  • Shared Session

Use cases of MATLAB MCP Integration

  • Controlling MATLAB simulations from LLM agents

  • Automating MATLAB tasks via external clients

  • Integrating MATLAB with other applications

  • Using MATLAB as a computational backend for AI models

FAQ from MATLAB MCP Integration

What is MCP?

Model Context Protocol (MCP) is a protocol that allows different applications to share information and interact with each other.

What MATLAB versions are supported?

R2023a or higher is recommended, but check MATLAB Engine API for Python compatibility.

How do I verify the MATLAB engine is shared?

Run matlab.engine.isEngineShared in MATLAB; it should return true or 1.

Where can I find the server logs?

Server logs are outputted to stderr and will appear in the MCP log files of your client application (e.g., Claude Desktop).

What are the future development plans?

Future plans include adding tools to set variables, run scripts, manage the workspace, handle more complex data types, and support Simulink models.