comsol-mcp
Enables AI assistants to drive COMSOL Multiphysics on Windows, including building geometry, setting parameters, physics and materials, generating meshes, running studies and solves, evaluating fields, exporting plots/CSV data, and sharing a live session with COMSOL Desktop.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
comsol-mcp
An MCP server that lets AI assistants drive COMSOL Multiphysics on Windows: build geometry, set parameters, generate meshes, solve studies, evaluate fields, and export plots — while your COMSOL Desktop stays connected to the same live session.
Built on MPh (the Python bridge to the COMSOL Java API) and the official MCP Python SDK.
MCP client (opencode / Claude Desktop / Cline / ...)
│ stdio
▼
comsol_mcp/server.py ──MPh + JPype──▶ COMSOL Multiphysics server (:2036)
▲
COMSOL Desktop (client mode)Features
Live session sharing — start the server, connect COMSOL Desktop in client mode, and watch changes appear in the GUI as the model is edited.
Full workflow — parameters, geometry, physics, materials, mesh, study, solve, evaluate, plot.
Escape hatch —
comsol_pythonruns arbitrary Python against the rawcom.comsol.model.ModelJava object, so nothing is out of reach.Long solves — background solving with status polling instead of blocked tool calls.
Safe saves — timestamped
.bak-*backups before overwriting a model.
Related MCP server: COMSOL MCP Server
Requirements
OS | Windows 10/11 (tested). Core logic is cross-platform; screenshot and some helpers are Windows-only. |
COMSOL | Multiphysics 6.x with a valid license (tested on 6.4.0.429). |
Python | 3.11+ |
Java | Bundled with COMSOL; no separate JDK needed. |
COMSOL_ROOT is optional — MPh discovers installed COMSOL versions from the Windows registry.
Installation
git clone https://github.com/Aknpa-Kacyraho/comsol-mcp
cd comsol-mcp
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .Verify:
python -c "import comsol_mcp; print(comsol_mcp.__version__)"
python tests\smoke_test.py
python tests\modeling_test.py
python tests\full_test.py
python tests\edge_test.pyEach test starts its own COMSOL server on a random port and cleans up after itself.
Configure your MCP client
opencode
{
"mcp": {
"comsol": {
"type": "local",
"command": [
"C:\\path\\to\\comsol-mcp\\.venv\\Scripts\\python.exe",
"C:\\path\\to\\comsol-mcp\\server.py"
],
"cwd": "C:\\path\\to\\comsol-mcp",
"environment": {
"PYTHONUTF8": "1",
"PYTHONIOENCODING": "utf-8"
},
"enabled": true,
"timeout": 3600000
}
}
}timeout is in milliseconds. Keep it large so long solves are not cut off.
Claude Desktop
{
"mcpServers": {
"comsol": {
"command": "C:\\path\\to\\comsol-mcp\\.venv\\Scripts\\python.exe",
"args": ["C:\\path\\to\\comsol-mcp\\server.py"],
"env": {
"PYTHONUTF8": "1",
"PYTHONIOENCODING": "utf-8"
}
}
}
}DeepSeek Harness (DSH)
Add an entry to home/cordis.patch.yml (under insert):
- id: mcp-comsol
name: '@deepseek-ai/dsh-mcp-client'
config:
serverName: comsol
transport: stdio
command: 'C:/path/to/comsol-mcp/.venv/Scripts/python.exe'
args:
- 'C:/path/to/comsol-mcp/server.py'
cwd: 'C:/path/to/comsol-mcp'
env:
PYTHONUTF8: '1'
PYTHONIOENCODING: 'utf-8'
toolCallTimeoutMs: 3600000Tools then appear as mcp__comsol__*. Restart DSH to pick up the change.
Cline / other stdio clients
Use the same command and args as Claude Desktop. Any client that speaks
stdio MCP works; the server only writes logs to logs/ and nothing to stdout
except protocol messages.
Tools
Tool | What it does |
| Connection state, port, loaded models, current model, background job status |
| Connect to an existing server or start one (default port 2036) |
| Disconnect and optionally shut the server down |
| Open a |
| Switch the active model when several are loaded |
| Save or save-as, with automatic backups |
| Structured model tree: parameters, geometry, physics, selections, materials, mesh, studies, results |
| Create/update/delete/build geometry features: Block, Cylinder, Sphere, Rectangle, Circle, Import, booleans |
| Create physics interfaces and features, bind selections, set properties |
| Named Box / Ball / Explicit selections, then reuse them in boundary conditions |
| Model health check: COMSOL-reported problems plus missing geometry/physics/material/mesh/study |
| Offline cheat sheets for geometry, heat, solid, flow, electrostatics, selection, mesh |
| Materials from built-in presets (copper/aluminum/steel/silicon/water/air) or custom properties |
| Read or set global parameters ( |
| Add a parametric sweep (parameter names + value lists, units inferred) |
| Build the mesh, optional density level 1–9 |
| Run a study, foreground or background |
| Evaluate an expression, return min/max/mean |
| Render a surface plot of any expression and export PNG |
| Export field values (with x/y/z coordinates) to CSV |
| List, remove from memory, or rename loaded models |
| Execute Python against the COMSOL Java API |
| Launch COMSOL Desktop and connect it to the running server |
| Capture the COMSOL window so the assistant can see the current UI |
Live desktop sharing
COMSOL supports a client–server mode where the server owns the model and Desktop is just a viewer.
Ask the assistant to run
comsol_start. A server starts on port 2036.Launch the client:
.\start_client.ps1or
& "<COMSOL_ROOT>\bin\win64\comsolmphclient.exe" -server localhost -port 2036Click Connect in the dialog.
Open the same model from the server's file list.
Edits made through MCP now appear in the Desktop tree as they happen.
If you prefer not to share a session, skip the Desktop part: MCP opens the
.mphfile independently and saves results you can reopen.
Examples
examples/heat_transfer_2d.py builds a 2D steady-state heat transfer model from scratch, solves it, evaluates the temperature field, and exports a PNG — a minimal end-to-end script using the same API the tools call.
python examples\heat_transfer_2d.pyEscape hatch
Anything the 24 tools do not cover can be done through comsol_python, which exposes model, java, client, mph, np:
ht = java.modelNode('comp1').physics('ht')
flux = ht.create('hf1', 'HeatFluxBoundary', 1)
flux.selection().set([2])
flux.set('q0', '1e4[W/m^2]')Useful Java API entry points:
Geometry:
java.modelNode('comp1').geom('geom1')Physics:
java.modelNode('comp1').physics('ht')Materials:
java.modelNode('comp1').material('mat1').propertyGroup('def')Mesh:
java.modelNode('comp1').mesh('mesh1')Study:
java.study('std1')Results:
java.result()
Environment variables
Variable | Default | Purpose |
| auto-detected | COMSOL installation root |
|
| Default server port |
| current directory | Where |
|
| Exit after this many idle seconds; |
Limitations
One COMSOL client per process: after
comsol_stop, the MCP process must be restarted before connecting again (JVM limitation).Cancelling a running solve is not exposed by the COMSOL Java API; a long solve must finish, or the COMSOL process must be restarted.
Progress reporting during solve is coarse — the job is either running or finished, no percentage.
comsol_screenshotbrings the COMSOL window to the foreground before capturing; it will briefly steal focus.Windows-specific helpers: screenshot, and launching Desktop. Everything else works wherever MPh works.
Acknowledgements
MPh — the Python bridge to the COMSOL Java API that makes all of this possible.
MCP Python SDK — server framework.
Prior art that informed the tool design: wjc9011/COMSOL_Multiphysics_MCP and Ching-Chiang/comsol-mcp. Their generic "feature type + properties" pattern is what our
comsol_geometry/comsol_physicstools follow.
Self-check
The 0.3.0 release went through a three-perspective review (user / designer / engineer). See docs/SELF-CHECK.md for the checklist and what was fixed.
Disclaimer
This project is not affiliated with, endorsed by, or supported by COMSOL AB. "COMSOL" and "COMSOL Multiphysics" are trademarks of COMSOL AB. You need your own valid COMSOL license to use this software.
License
MIT. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Connect your AI assistant to Blender for 3D modeling, Geometry Nodes, materials, lighting, animation, rendering and export. Inspect real scenes and viewport images, refine the result and restore checkpoints. OAuth connects your chat to Blender Bridge Desktop on an online Windows 10/11 x64 computer running Blender 4.2+. The chat can run on another device. Requires an active Blender Bridge account; 7-day trial available. AI model access is separate.
Connect AI assistants to your approved computer for files, commands, browser and desktop tasks.
Remote Desktop Commander: use files, terminal and processes on your own computers from any AI app.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI agents to automate multiphysics simulations in COMSOL Multiphysics, covering model management, geometry building, physics configuration, and results visualization. It supports complex simulation workflows through the MCP protocol and includes integrated knowledge retrieval for documentation and troubleshooting.93989MIT
- AlicenseBqualityCmaintenanceEnables AI agents to automate COMSOL Multiphysics simulations, including model management, geometry building, physics configuration, meshing, solving, and results visualization through the MCP protocol.78MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to automate COMSOL Multiphysics simulations, including model management, geometry building, physics configuration, meshing, solving, and results visualization via the MCP protocol.MIT
- AlicenseCqualityCmaintenanceEnables AI agents to read and write .mph model files, control the COMSOL desktop GUI in real time, and run complete modeling, meshing, solving, and post-processing workflows.232MIT