-
Notifications
You must be signed in to change notification settings - Fork 14
feat: Add MATLAB MCP server #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add MATLAB MCP server #55
Conversation
This commit introduces a new MCP server, `matlab-server`, allowing agents to execute MATLAB code. Key features: - Executes MATLAB code via `matlab -batch`. - Supports both text output and capturing plots as PNG images. - Includes comprehensive README for setup and usage. - Provides unit tests with mocking for MATLAB interaction. The server structure is based on the `mathematica-check` server. It checks for MATLAB availability and handles errors during execution. Includes: - Server logic in `servers/matlab-server/src/matlab_server/server.py`. - Project files: `pyproject.toml`, `setup.py`. - Documentation: `servers/matlab-server/README.md`. - Tests: `servers/matlab-server/tests/test_server.py` and `pytest.ini`. - Python version file: `servers/matlab-server/.python-version` (set to 3.11.8).
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new MATLAB MCP server to execute MATLAB code and capture both text and plot outputs. Key changes include adding the server logic and MCP tool in Python, a comprehensive suite of unit tests using async mocks, and updated configuration files (setup.py, pyproject.toml, pytest.ini, and README).
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
servers/matlab-server/tests/test_server.py | Comprehensive unit tests covering MATLAB installation checks, text/plot code execution, and global state resets. |
servers/matlab-server/src/matlab_server/server.py | Server logic for checking MATLAB availability, executing MATLAB code, and handling plot output. |
servers/matlab-server/src/matlab_server/init.py | Package initialization file. |
servers/matlab-server/setup.py | Build and packaging configuration for the MATLAB server. |
servers/matlab-server/pytest.ini | Pytest configuration ensuring proper module discovery and asyncio mode setup. |
servers/matlab-server/pyproject.toml | Project metadata and dependency configuration. |
servers/matlab-server/README.md | Updated documentation detailing installation, usage, and integration with MCP clients. |
servers/matlab-server/.python-version | Specifies the required Python version (3.11.8) for the MATLAB server. |
.python-version | Updated global Python version to 3.11.8. |
# The user's code should generate a figure. We then save it. | ||
# `print('-dpng', '{filepath}')` saves the current figure. | ||
# We add `exit;` to ensure MATLAB closes after execution. | ||
matlab_command_code = f""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using textwrap.dedent to build multiline MATLAB command strings so that unintended leading whitespace does not affect MATLAB's interpretation of the script.
matlab_command_code = f""" | |
matlab_command_code = textwrap.dedent(f""" |
Copilot uses AI. Check for mistakes.
PR Code Suggestions ✨Explore these optional code suggestions:
|
User description
This commit introduces a new MCP server,
matlab-server
, allowing agents to execute MATLAB code.Key features:
matlab -batch
.The server structure is based on the
mathematica-check
server. It checks for MATLAB availability and handles errors during execution.Includes:
servers/matlab-server/src/matlab_server/server.py
.pyproject.toml
,setup.py
.servers/matlab-server/README.md
.servers/matlab-server/tests/test_server.py
andpytest.ini
.servers/matlab-server/.python-version
(set to 3.11.8).PR Type
Enhancement
Description
Add complete MATLAB MCP server implementation
Support text output and PNG plot generation
Include comprehensive test suite with mocking
Provide detailed documentation and setup instructions
Changes walkthrough 📝
5 files
Package setup configuration for MATLAB server
Update Python version to 3.11.8
Set Python version for MATLAB server
Project metadata and dependencies configuration
Pytest configuration for testing
1 files
Python package initialization file
1 files
Core MATLAB MCP server implementation
1 files
Comprehensive test suite with mocking
1 files
Complete documentation and setup guide