matlab-simulink-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. matlab_simulink_mcp-0.1.0/PKG-INFO +169 -0
  2. matlab_simulink_mcp-0.1.0/README.md +155 -0
  3. matlab_simulink_mcp-0.1.0/pyproject.toml +33 -0
  4. matlab_simulink_mcp-0.1.0/setup.cfg +4 -0
  5. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/__init__.py +0 -0
  6. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/__main__.py +13 -0
  7. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/data/__init__.py +0 -0
  8. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/data/blacklist.txt +39 -0
  9. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/data/simlib_db.json +20023 -0
  10. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/functions.py +194 -0
  11. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/installer/__init__.py +0 -0
  12. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/installer/installer.py +160 -0
  13. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/installer/launcher.py +45 -0
  14. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/installer/win_elevate.py +18 -0
  15. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/log_utils.py +112 -0
  16. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/security.py +56 -0
  17. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/server.py +54 -0
  18. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp/state.py +106 -0
  19. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp.egg-info/PKG-INFO +169 -0
  20. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp.egg-info/SOURCES.txt +22 -0
  21. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp.egg-info/dependency_links.txt +1 -0
  22. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp.egg-info/entry_points.txt +2 -0
  23. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp.egg-info/requires.txt +2 -0
  24. matlab_simulink_mcp-0.1.0/src/matlab_simulink_mcp.egg-info/top_level.txt +1 -0
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: matlab-simulink-mcp
3
+ Version: 0.1.0
4
+ Summary: An MCP server for allowing LLMs to interact with MATLAB and Simulink
5
+ Author: Rohail
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: <3.13,>=3.10
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: fastmcp>=2.12.2
13
+ Requires-Dist: platformdirs>=4.4.0
14
+
15
+ # MATLAB Simulink MCP Server
16
+
17
+ [![PyPI version](https://img.shields.io/pypi/v/matlab-simulink-mcp.svg)](https://pypi.org/project/matlab-simulink-mcp/)
18
+ [![Python versions](https://img.shields.io/pypi/pyversions/matlab-simulink-mcp.svg)](https://pypi.org/project/matlab-simulink-mcp/)
19
+
20
+ This [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol) server allows MCP clients (such as Claude Desktop or other LLM-based agents) to interact with **MATLAB** and **Simulink** in real time. It runs locally and is built on top of the [FastMCP 2.0](https://gofastmcp.com/getting-started/welcome) library.
21
+
22
+ ## Features
23
+
24
+ - Read, write, and run MATLAB code and scripts
25
+ - Parse and interact with Simulink files
26
+ - Access MATLAB workspace variables and outputs (including visualizations)
27
+ - Basic safety layer to prevent execution of unsafe commands (configurable)
28
+ - Non-blocking execution (async MATLAB engine calls)
29
+ - Automatic installation of MATLAB Engine package if unavailable
30
+
31
+ ## Requirements
32
+
33
+ - **MATLAB** R2022b or later
34
+ - **Python** 3.10–3.12 (check MATLAB's [supported versions](https://www.mathworks.com/support/requirements/python-compatibility.html))
35
+
36
+ ## Installation
37
+
38
+ ### Option 1 — Download Binary (MATLAB R2025a only)
39
+
40
+ If you don’t want to interact with Python at all, you can download a prebuilt **exe/app** from the [Releases](../../releases) page and run it directly. In that case you can skip the steps below.
41
+
42
+ ### Option 2 — From Source
43
+
44
+ 1. Clone the repository:
45
+
46
+ ```bash
47
+ git clone https://github.com/rohailamalik/matlab-simulink-mcp
48
+ cd matlab-simulink-mcp
49
+
50
+ 2. Create a Python virtual environment (recommended: [uv](https://pypi.org/project/uv/0.1.32/)):
51
+
52
+ ```bash
53
+ uv venv --python 3.12 # match Python to your MATLAB-supported version
54
+ source .venv/Scripts/activate # on macOS/Linux: source .venv/bin/activate
55
+ uv sync
56
+ ```
57
+
58
+ Without uv, first download a Python version manually:
59
+
60
+ ```bash
61
+ python3.12 -m venv .venv
62
+ source .venv/bin/activate
63
+ pip install -r requirements.txt
64
+ pip install .
65
+ ```
66
+
67
+ 3. Alternatively, skip step 1, create virtual environment and install directly via PyPI:
68
+
69
+ ```bash
70
+ uv pip install matlab-simulink-mcp
71
+ # or
72
+ pip install matlab-simulink-mcp
73
+ ```
74
+
75
+ 4. On first run, if the MATLAB Engine is not installed, the server will open a console window and guide you through installation.
76
+
77
+ - This requires admin permission and the server will request for it.
78
+ - If you prefer to install manually, install a [matching PyPi version](https://pypi.org/project/matlabengine/#history) or from your [MATLAB installation](https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html).
79
+
80
+ ## Configuration (Claude Desktop)
81
+
82
+ 1. Install [Claude Desktop](https://claude.ai/download).
83
+
84
+ 2. Open Settings → Developer → Edit Config.
85
+
86
+ 3. In the `claude_desktop_config.json`, add or update:
87
+
88
+ ```json
89
+ {
90
+ "mcpServers": {
91
+ "MATLAB_Simulink_MCP": {
92
+ "command": "C:/Data/Research/Doctoral/src/matlab-simulink-mcp/.venv/Scripts/python.exe",
93
+ "args": ["-m", "matlab_simulink_mcp"]
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ On macOS/Linux, use `absolute-path-to/.venv/bin/python` in `command`.
100
+
101
+ If using the standalone exe/app, just put absolute path to it in `command` and omit args.
102
+
103
+ **Note**: Only use `/` or `\\` in the paths, not `\`.
104
+
105
+ 4. Save and restart Claude Desktop. (Ensure it is fully closed in Task Manager/Activity Monitor.)
106
+
107
+ 5. On first launch, the server may open multiple consoles to install MATLAB Engine. Interact with one, complete installation, then restart Claude if needed.
108
+
109
+ 6. Check running status in Settings → Developer, or click the equalizer button in the chat box.
110
+
111
+ 7. The server logs outputs and errors to both Claude's and its own log file. To keep a log file tracking console open, add `--console` in Claude config args.
112
+
113
+ - Claude MCP logs (Windows): `%APPDATA%\Claude\logs\mcp-server-MatlabMCP.log`
114
+ - Claude MCP logs (macOS): `~/Library/Logs/Claude/mcp-server-MatlabMCP.log`
115
+ - Server logs: written to your user log directory (or configured via `.env`).
116
+
117
+ ## Debugging
118
+
119
+ FastMCP 2.0 includes an MCP Inspector for manual testing without an LLM client. This launches a UI to send dummy requests directly to the server.
120
+
121
+ ```bash
122
+ cd scripts
123
+ fastmcp dev debugger.py
124
+ ```
125
+
126
+ ## Repository Structure
127
+
128
+ ```txt
129
+
130
+ matlab-simulink-mcp/
131
+ ├─ scripts
132
+ │ ├─ debugger.py # Entry point for MCP inspector
133
+ ├─ src/matlab_simulink_mcp/
134
+ │ ├─ data/ # Data files and resources
135
+ │ ├─ installer/ # MATLAB Engine installer
136
+ │ │ ├─ installer.py
137
+ │ │ ├─ launcher.py
138
+ │ │ └─ win_elevate.py
139
+ │ ├─ functions.py # Baseline MCP tool functions
140
+ │ ├─ log_utils.py # Logging utilities
141
+ │ ├─ security.py # Safety layer for code execution
142
+ │ ├─ server.py # Main server script
143
+ │ ├─ state.py # Server lifespan objects (logger, engine)
144
+ │ ├─ __main__.py # Main entry point
145
+ ├─ .env # Optional config (e.g. LOG_DIR)
146
+ ├─ pyproject.toml # Project metadata and dependencies
147
+ ├─ requirements.txt # Package dependencies for pip
148
+ ├─ uv.lock # Package dependencies for uv
149
+ └─ README.md # This file
150
+
151
+ ```
152
+
153
+ ## FAQ
154
+
155
+ Q: Which Python version should I install?
156
+
157
+ A: Match it to the highest Python version supported by your MATLAB release (see MathWorks docs).
158
+
159
+ Q: The console disappears too quickly!
160
+
161
+ A: Add `--console` in your Claude config args to keep the server console open.
162
+
163
+ Q: Multiple installer consoles opened on first run.
164
+
165
+ A: This is expected if Claude sends multiple startup requests. Complete one installation, then restart Claude Desktop.
166
+
167
+ ## Contributing
168
+
169
+ Pull requests are welcome! Feel free to submit one or open an issue.
@@ -0,0 +1,155 @@
1
+ # MATLAB Simulink MCP Server
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/matlab-simulink-mcp.svg)](https://pypi.org/project/matlab-simulink-mcp/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/matlab-simulink-mcp.svg)](https://pypi.org/project/matlab-simulink-mcp/)
5
+
6
+ This [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol) server allows MCP clients (such as Claude Desktop or other LLM-based agents) to interact with **MATLAB** and **Simulink** in real time. It runs locally and is built on top of the [FastMCP 2.0](https://gofastmcp.com/getting-started/welcome) library.
7
+
8
+ ## Features
9
+
10
+ - Read, write, and run MATLAB code and scripts
11
+ - Parse and interact with Simulink files
12
+ - Access MATLAB workspace variables and outputs (including visualizations)
13
+ - Basic safety layer to prevent execution of unsafe commands (configurable)
14
+ - Non-blocking execution (async MATLAB engine calls)
15
+ - Automatic installation of MATLAB Engine package if unavailable
16
+
17
+ ## Requirements
18
+
19
+ - **MATLAB** R2022b or later
20
+ - **Python** 3.10–3.12 (check MATLAB's [supported versions](https://www.mathworks.com/support/requirements/python-compatibility.html))
21
+
22
+ ## Installation
23
+
24
+ ### Option 1 — Download Binary (MATLAB R2025a only)
25
+
26
+ If you don’t want to interact with Python at all, you can download a prebuilt **exe/app** from the [Releases](../../releases) page and run it directly. In that case you can skip the steps below.
27
+
28
+ ### Option 2 — From Source
29
+
30
+ 1. Clone the repository:
31
+
32
+ ```bash
33
+ git clone https://github.com/rohailamalik/matlab-simulink-mcp
34
+ cd matlab-simulink-mcp
35
+
36
+ 2. Create a Python virtual environment (recommended: [uv](https://pypi.org/project/uv/0.1.32/)):
37
+
38
+ ```bash
39
+ uv venv --python 3.12 # match Python to your MATLAB-supported version
40
+ source .venv/Scripts/activate # on macOS/Linux: source .venv/bin/activate
41
+ uv sync
42
+ ```
43
+
44
+ Without uv, first download a Python version manually:
45
+
46
+ ```bash
47
+ python3.12 -m venv .venv
48
+ source .venv/bin/activate
49
+ pip install -r requirements.txt
50
+ pip install .
51
+ ```
52
+
53
+ 3. Alternatively, skip step 1, create virtual environment and install directly via PyPI:
54
+
55
+ ```bash
56
+ uv pip install matlab-simulink-mcp
57
+ # or
58
+ pip install matlab-simulink-mcp
59
+ ```
60
+
61
+ 4. On first run, if the MATLAB Engine is not installed, the server will open a console window and guide you through installation.
62
+
63
+ - This requires admin permission and the server will request for it.
64
+ - If you prefer to install manually, install a [matching PyPi version](https://pypi.org/project/matlabengine/#history) or from your [MATLAB installation](https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html).
65
+
66
+ ## Configuration (Claude Desktop)
67
+
68
+ 1. Install [Claude Desktop](https://claude.ai/download).
69
+
70
+ 2. Open Settings → Developer → Edit Config.
71
+
72
+ 3. In the `claude_desktop_config.json`, add or update:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "MATLAB_Simulink_MCP": {
78
+ "command": "C:/Data/Research/Doctoral/src/matlab-simulink-mcp/.venv/Scripts/python.exe",
79
+ "args": ["-m", "matlab_simulink_mcp"]
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ On macOS/Linux, use `absolute-path-to/.venv/bin/python` in `command`.
86
+
87
+ If using the standalone exe/app, just put absolute path to it in `command` and omit args.
88
+
89
+ **Note**: Only use `/` or `\\` in the paths, not `\`.
90
+
91
+ 4. Save and restart Claude Desktop. (Ensure it is fully closed in Task Manager/Activity Monitor.)
92
+
93
+ 5. On first launch, the server may open multiple consoles to install MATLAB Engine. Interact with one, complete installation, then restart Claude if needed.
94
+
95
+ 6. Check running status in Settings → Developer, or click the equalizer button in the chat box.
96
+
97
+ 7. The server logs outputs and errors to both Claude's and its own log file. To keep a log file tracking console open, add `--console` in Claude config args.
98
+
99
+ - Claude MCP logs (Windows): `%APPDATA%\Claude\logs\mcp-server-MatlabMCP.log`
100
+ - Claude MCP logs (macOS): `~/Library/Logs/Claude/mcp-server-MatlabMCP.log`
101
+ - Server logs: written to your user log directory (or configured via `.env`).
102
+
103
+ ## Debugging
104
+
105
+ FastMCP 2.0 includes an MCP Inspector for manual testing without an LLM client. This launches a UI to send dummy requests directly to the server.
106
+
107
+ ```bash
108
+ cd scripts
109
+ fastmcp dev debugger.py
110
+ ```
111
+
112
+ ## Repository Structure
113
+
114
+ ```txt
115
+
116
+ matlab-simulink-mcp/
117
+ ├─ scripts
118
+ │ ├─ debugger.py # Entry point for MCP inspector
119
+ ├─ src/matlab_simulink_mcp/
120
+ │ ├─ data/ # Data files and resources
121
+ │ ├─ installer/ # MATLAB Engine installer
122
+ │ │ ├─ installer.py
123
+ │ │ ├─ launcher.py
124
+ │ │ └─ win_elevate.py
125
+ │ ├─ functions.py # Baseline MCP tool functions
126
+ │ ├─ log_utils.py # Logging utilities
127
+ │ ├─ security.py # Safety layer for code execution
128
+ │ ├─ server.py # Main server script
129
+ │ ├─ state.py # Server lifespan objects (logger, engine)
130
+ │ ├─ __main__.py # Main entry point
131
+ ├─ .env # Optional config (e.g. LOG_DIR)
132
+ ├─ pyproject.toml # Project metadata and dependencies
133
+ ├─ requirements.txt # Package dependencies for pip
134
+ ├─ uv.lock # Package dependencies for uv
135
+ └─ README.md # This file
136
+
137
+ ```
138
+
139
+ ## FAQ
140
+
141
+ Q: Which Python version should I install?
142
+
143
+ A: Match it to the highest Python version supported by your MATLAB release (see MathWorks docs).
144
+
145
+ Q: The console disappears too quickly!
146
+
147
+ A: Add `--console` in your Claude config args to keep the server console open.
148
+
149
+ Q: Multiple installer consoles opened on first run.
150
+
151
+ A: This is expected if Claude sends multiple startup requests. Complete one installation, then restart Claude Desktop.
152
+
153
+ ## Contributing
154
+
155
+ Pull requests are welcome! Feel free to submit one or open an issue.
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "matlab-simulink-mcp"
7
+ version = "0.1.0"
8
+ description = "An MCP server for allowing LLMs to interact with MATLAB and Simulink"
9
+ authors = [
10
+ { name = "Rohail"}
11
+ ]
12
+ license = { text = "MIT" }
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent"
17
+ ]
18
+
19
+ readme = { file = "README.md", content-type = "text/markdown" }
20
+ requires-python = ">=3.10,<3.13"
21
+ dependencies = [
22
+ "fastmcp>=2.12.2",
23
+ "platformdirs>=4.4.0",
24
+ ]
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+
29
+ [tool.setuptools.package-data]
30
+ "matlab_simulink_mcp" = ["data/*.txt", "data/*.json", "data/helpers/*.py"]
31
+
32
+ [project.scripts]
33
+ matlab_simulink_mcp = "matlab_simulink_mcp.__main__:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ import argparse
2
+ import matlab_simulink_mcp.server as server
3
+
4
+ def main():
5
+ parser = argparse.ArgumentParser()
6
+ parser.add_argument("--console", action="store_true", help="Keep console open.")
7
+ args = parser.parse_args()
8
+
9
+ server.console = args.console
10
+ server.run()
11
+
12
+ if __name__ == "__main__":
13
+ main()
@@ -0,0 +1,39 @@
1
+ # The commands mentioned in this file are not allowed to be used by the LLM for safety reasons.
2
+ # The LLM is also not allowed to use absolute paths (and thus access anything not on MATLAB path).
3
+ # ! is only blocked in the code when used at the beginning of the line i.e. as a proper command
4
+
5
+ !
6
+ eval
7
+ rehash
8
+ feval
9
+ system
10
+ unix
11
+ dos
12
+ builtin
13
+ str2func
14
+ perl
15
+ python
16
+ pyenv
17
+ py.
18
+ javaobject
19
+ javamethod
20
+ javamethodedt
21
+ javaclasspath
22
+ javaaddpath
23
+ matlab.desktop.editor.opendocument
24
+ matlab.desktop.editor.save
25
+ addpath
26
+ rmpath
27
+ cd
28
+ userpath
29
+ path
30
+ savepath
31
+ restoredefaultpath
32
+ genpath
33
+ which
34
+ what
35
+ matlabroot
36
+ uigetdir
37
+ uigetfile
38
+ uiopen
39
+ uiputfile