Comsol MCP
非官方 COMSOL MCP 学习项目:通过 Java Shell 控制已打开的 COMSOL Desktop GUI
Ask AI about Comsol MCP
Powered by Claude · Grounded in docs
I know everything about Comsol MCP. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
COMSOL MCP
This repository contains an MCP server for controlling an already-open COMSOL Desktop GUI through the COMSOL Java Shell.
This is an unofficial educational project. It is intended for learning, tutorials, and local automation experiments, not as a COMSOL-supported integration.
The server is designed for GUI-visible edits: Codex pastes COMSOL Java API commands into the Java Shell of the currently open COMSOL Desktop model, then executes them with Ctrl+Enter.
Scope
This repository currently publishes only the GUI Java Shell MCP implementation.
COMSOL can also be controlled through the Python mph package in a background workflow, but that implementation is not included here. If you need the background route, keep it as a separate project with its own source ownership and license review.
Requirements
- Windows
- COMSOL Desktop 6.3 or newer
- COMSOL Desktop and the target model already open
- Java Shell visible
Automatic ribbon clicking is disabled by default because localized COMSOL ribbon automation can trigger COMSOL UI errors.
Setup
.\setup_venv.ps1
Optional local settings:
Copy-Item .\env.local.example .\env.local
Run
.\start_server.ps1
Codex global config should point mcp_servers.comsol_gui to:
E:\AgentCOMSOL\AgentCOMSOL-main\comsol-gui-mcp\.venv\Scripts\python.exeE:\AgentCOMSOL\AgentCOMSOL-main\comsol-gui-mcp\server.py
MCP Tools
gui_status()lists COMSOL GUI processes/windows and whether Java Shell is visible.ensure_java_shell()finds Java Shell and returns a manual action if it is not visible.execute_java_shell(code, allow_non_model_code=false, timeout_sec=30)pastes commands and executes them withCtrl+Enter.set_global_parameter(name, value, description=null)sets a global parameter through Java Shell.get_java_shell_output()tries to read visible Java Shell text through UI Automation.
Safe Command Policy
By default, execute_java_shell only accepts non-empty executable lines that start with model.. Use allow_non_model_code=true only when you intentionally need broader Java Shell commands.
First Validation
- Open COMSOL Desktop and a test model.
- Open
Home > Windows > Java Shell. - Call
gui_status(). - Call
set_global_parameter("codex_gui_mcp_probe", "1"). - Confirm the parameter appears in the GUI.
- Clean up with
execute_java_shell("model.param().remove(\"codex_gui_mcp_probe\");").
Notice
This is not an official COMSOL project and is not affiliated with, endorsed by, or supported by COMSOL AB. COMSOL product names and trademarks belong to their respective owner.
The code is provided for learning and tutorial use under the MIT License. Use it with local test models first, and review generated Java API commands before applying them to important COMSOL models.
