COMSOL MCP
This server provides a live COMSOL Multiphysics automation bridge, letting you launch/connect to the COMSOL GUI and drive modeling, meshing, solving, evaluation, and export in real time.
Manage GUI sessions: launch, connect to, check status of, and shut down the COMSOL Desktop live bridge.
Model lifecycle: create new models, load/save .mph files, and inspect the current model structure.
Geometry creation: add blocks, cylinders, spheres, perform boolean operations, and import CAD geometry.
Physics & materials: add physics interfaces (heat transfer, fluid flow, solid mechanics, etc.) and assign materials with selections.
Meshing: build meshes on the model.
Studies & solving: add stationary, time-dependent, parametric, or eigenfrequency studies; run solvers and check solution status.
Evaluation & export: evaluate expressions on datasets and export plots/data to files.
Advanced control: execute arbitrary COMSOL Java API code and generate standalone compilable COMSOL Java model sources without needing COMSOL installed.
Provides integration with COMSOL Multiphysics, enabling AI agents to create, load, edit, and save .mph model files; control the COMSOL desktop GUI; build geometry; add physics and materials; generate meshes; set up and run studies and solvers; and evaluate and export simulation results.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@COMSOL MCP Load my heat sink model, build mesh, and run a stationary study."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
COMSOL MCP
A Model Context Protocol (MCP) server for COMSOL Multiphysics that lets AI agents (such as Claude Desktop / Codex):
Read and write
.mphmodel filesControl the COMSOL desktop GUI in real time (embedded GUI bridge; operations are visible live on the desktop)
Complete the full modeling → definition → computation → post-processing pipeline
Work from any working directory (independent of cwd; automatically detects the COMSOL installation path)
Run in dry-run mode when COMSOL is not available, for development and testing
Architecture
AI Agent ──MCP(stdio)──► comsol_mcp (Python) ──HTTP/JSON──► ComsolBridge (Java, 在 COMSOL JVM 内)
│
└──comsolbatch (无头回退)Embedded GUI bridge (real-time control):
launch_guistarts the COMSOL desktop and loadsComsolBridgeinside its JVM; the bridge runs a local HTTP service and holds theModelobject. The MCP server invokes the COMSOL Java API through it in real time, so you can watch geometry/physics/solver progress update live on the desktop.Headless batch (fallback/batch): when no GUI session exists, operations are accumulated into a Java program and run with
comsolcompile+comsolbatch. The same modeling logic works in both modes.dry-run: enabled automatically when COMSOL is not installed on the local machine; all tools remain callable (returning simulated results), which is convenient for onboarding and testing.
Related MCP server: COMSOL MCP Server
Requirements
COMSOL Multiphysics 5.x / 6.x (the standard desktop license includes the Java API)
Python 3.10+
(Optional) No Node required — the dashboard is plain static HTML
Installation
cd comsol-mcp
pip install .⚠️ Configure the COMSOL path (required for non-default installations)
The program locates COMSOL in the following order, but automatic detection only covers standard locations:
The
COMSOL_HOMEenvironment variable (most reliable; recommended to set explicitly when configuring MCP)Windows registry (
COMSOLROOT)Standard directories:
C:\Program Files\COMSOL\COMSOLxx,D:/...,E:/..., and their WSL / Linux / macOS equivalents
If COMSOL is installed on a non-default drive or in a custom directory (for example
C:\D\Program Files\COMSOL\COMSOL62\Multiphysics), automatic detection will not find it and you must setCOMSOL_HOME. All users are strongly advised to writeCOMSOL_HOMEintoenvwhen configuring MCP rather than relying on automatic detection — otherwise the agent may mistakenly conclude COMSOL is not installed and fall back to dry-run.
# Windows 示例:指向 Multiphysics 目录最简明(也兼容版本目录 .../COMSOL62 或根目录 .../COMSOL)
export COMSOL_HOME="C:\Program Files\COMSOL\COMSOL62\Multiphysics"Compile the Java bridge (requires COMSOL to be on PATH or in COMSOL_HOME):
comsol-mcp compile-bridgeQuick Start
Add it to your MCP client configuration (OpenCode: in the mcp block of ~/.config/opencode/opencode.json; Claude Desktop: in the mcpServers block of claude_desktop_config.json):
Key point:
COMSOL_HOMEmust be written intoenv. Do not let the AI probe/guess a fixed default path (such asC:\Program Files\COMSOL) — it cannot find custom installation directories, will misjudge COMSOL as "not installed", and fall back to dry-run. Machines without COMSOL installed can still dry-run (generate_model_javaand other tools that do not need COMSOL work as usual).
{
"mcp": {
"comsol": {
"type": "local",
"command": ["C:\\path\\to\\comsol-mcp.exe"],
"args": [],
"env": { "COMSOL_HOME": "C:\\D\\Program Files\\COMSOL\\COMSOL62\\Multiphysics" }
}
}
}Then have the AI work like this:
launch_gui()— open the COMSOL desktop and load the bridge (visible in real time).new_model()/load_model("x.mph")add_block("geom1", 3, [1,1,1], [0,0,0])add_physics("ht", "ht")(heat transfer)build_mesh()→add_study("std1", "Stationary")→run_solver("std1")evaluate("T")to retrieve results,save_model("out.mph")to save.
MCP Tool List
类别 | 工具 |
会话 / GUI |
|
模型读写 |
|
几何 |
|
物理 / 材料 |
|
网格 / 研究 / 求解 |
|
后处理 |
|
通用 |
|
无 COMSOL 准备 |
|
See USAGE.md for details.
Dry-Run Mode
When COMSOL cannot be detected, the package automatically enters dry-run: tools return simulated data and the MCP server can still be imported and tested. Set COMSOL_MCP_DRYRUN=1 to force it on.
Machines without COMSOL can also use
generate_model_javato produce standalone compilable Java model source code, then compile it to.mphwithcomsolcompile+comsolbatchon a machine that has COMSOL. See "Two Run Modes" in USAGE.md.
Verification Status
✅ In the local build environment:
py_compilepasses for the whole package, the MCP server starts, and the dry-run logic chain is exercisable.⚠️ Real COMSOL execution must be verified on a machine with COMSOL installed: run
comsol-mcp compile-bridgeand actually run a model. The Java bridge is written to the COMSOL Java API specification, but interfaces may need minor adjustments across versions (see the note at the top ofcomsol_mcp/bridge/ComsolBridge.java).
License
MIT — see LICENSE.
Available Tools
23 toolsadd_blockC
Add a block (box) to a geometry sequence.
Inputs: pos (required), dims (required), size (required), geom_tag (required), +1 more. Returns: result
add_cylinderC
Add a cylinder to a geometry sequence.
Inputs: h (required), r (required), pos (required), dims (required), +3 more. Returns: result
add_materialC
Add a material to the model.
Inputs: tag (required), material (required), selection. Returns: result
add_physicsB
Add a physics interface (ht, spf, tds, es, solid, ...).
Inputs: tag (required), interface (required), settings. Returns: result
add_sphereC
Add a sphere to a geometry sequence.
Inputs: r (required), pos (required), dims (required), geom_tag (required), +1 more. Returns: result
add_studyB
Add a study (Stationary|TimeDependent|Parametric|Eigenfrequency).
Inputs: tag (required), study_type (required), settings. Returns: result
boolean_opC
Boolean combine geometry features (union|intersect|difference).
Inputs: inputs (required), geom_tag (required), operation (required). Returns: result
build_meshD
Build the mesh.
Inputs: mesh_tag. Returns: result
connect_guiB
Connect to an already-running COMSOL GUI bridge.
Inputs: host, port. Returns: result
evaluateC
Evaluate an expression (or global evaluation) and return data.
Inputs: expr (required), dataset. Returns: result
exec_model_apiA
Run arbitrary COMSOL Java API code.
Provide either a full class with public static String run(Model model),
or a Java snippet body; it will be wrapped automatically and executed in
the COMSOL JVM (best-effort in live mode, always via compile+run in
batch mode).
Inputs: code (required). Returns: result
export_resultsC
Export results (plot/data) to a file.
Inputs: filename (required), export_type (required), settings. Returns: result
generate_model_javaA
Generate a standalone, compilable COMSOL Java model source file.
Works WITHOUT COMSOL installed. Use it on a COMSOL-less machine to prepare a
Java model, then move the file to a COMSOL machine and compile it:
comsolcompile .java
comsolbatch -java
spec may carry geometries/physics/materials/studies/save to shape the code.
The produced file still needs COMSOL to actually compile into a .mph.
Inputs: filepath (required), spec, class_name, model_version. Returns: result
gui_statusA
Report the current GUI/bridge session state.
Inputs: no named parameters. Returns: result
import_geometryC
Import a geometry from a CAD/file format.
Inputs: filename (required), geom_tag (required), type. Returns: result
launch_guiA
Launch the COMSOL desktop GUI with the live bridge loaded.
Operations issued afterwards drive the visible GUI in real time.
Inputs: port, model_path. Returns: result
load_modelC
Load a .mph model from disk.
Inputs: path (required). Returns: result
model_infoA
Return the structure of the current model.
Inputs: no named parameters. Returns: result
new_modelB
Create a new empty model.
Inputs: version. Returns: result
run_solverC
Run the solver for a study.
Inputs: study_tag (required). Returns: result
save_modelB
Save the current model to a .mph file.
Inputs: path. Returns: result
shutdown_guiA
Stop the COMSOL GUI bridge session.
Inputs: no named parameters. Returns: result
solver_statusB
Report whether a study has been solved.
Inputs: study_tag (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Each tool targets a distinct stage or resource: geometry primitives, physics/material, mesh/study/solver, results, model files, GUI bridge, and code generation. Even similar lifecycle tools such as launch_gui vs connect_gui and solver_status vs gui_status are clearly separated. exec_model_api is intentionally broad but explicitly labeled as arbitrary Java API, so it does not create real ambiguity.
Many tools follow a verb_noun pattern, but the set is mixed: add_* dominates creation, while solver_status, gui_status, and model_info use noun-first naming, and boolean_op lacks a verb entirely. The names are readable and all lowercase with underscores, but the conventions are not consistent enough for a strong score.
With 23 tools, this sits in the 16-25 'heavy' band. The breadth is somewhat justified by COMSOL's wide scope spanning geometry, physics, meshing, solving, GUI, file I/O, and code generation, but the count feels slightly large for an MCP tool surface.
The set covers the core COMSOL workflow end-to-end: new/load/save models, geometry creation, physics and materials, meshing, studies, solving, evaluation, export, and GUI bridging. Fine-grained editing of existing features, material properties, or mesh settings is missing, but exec_model_api and generate_model_java provide workarounds for those gaps.
Maintenance
Related MCP Connectors
Parametric 3D CAD for AI agents: build print-ready parts, check them, export STL, 3MF or STEP.
Build, validate, and deploy multi-agent AI solutions from any AI environment.
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Connect AI assistants to your approved computer for files, commands, browser and desktop tasks.
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
- AlicenseBqualityDmaintenanceMCP Server for COMSOL Multiphysics simulation automation via AI agents.782MIT
- 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