| name | comsol-mph-analyzer |
| description | COMSOL Multiphysics toolkit for .mph model analysis, input preparation, mesh/geometry editing, and MCP connectivity. Use when (1) user provides a .mph file and wants to understand its contents, (2) preparing simulation inputs or parameter sweeps, (3) modifying .mph parameters without COMSOL, (4) generating Java API code from .mph models, (5) editing mphtxt mesh or STL geometry files (translate, rotate, scale, mirror), (6) converting STL to COMSOL mphtxt format, (7) checking COMSOL installation and MCP readiness, (8) setting up COMSOL MCP server for Claude control. Triggers on: .mph files, COMSOL model, analyze mph, parameter sweep, comsolbatch, mesh editing, STL editing, mphtxt, COMSOL MCP, simulation inputs. |
COMSOL Toolkit
4-module toolkit for COMSOL Multiphysics workflows. Python stdlib only (no external packages required).
Module 1: Value Extraction
Extract parameters, physics, materials, species, geometry, and metadata from .mph files.
python scripts/analyze_mph.py model.mph
python scripts/analyze_mph.py model.mph --parameters
python scripts/analyze_mph.py model.mph --physics
python scripts/analyze_mph.py model.mph --json
python scripts/analyze_mph.py model.mph --tree
python scripts/analyze_mph.py model.mph --export-xml DIR
See references/mph_format.md for .mph file format details.
Module 2: Input Preparation
Prepare simulation inputs: parameter files, .mph XML modification, Java API code generation.
python scripts/prepare_inputs.py model.mph --extract
python scripts/prepare_inputs.py model.mph --paramfile out.txt
python scripts/prepare_inputs.py model.mph --paramfile out.txt --set "T_in=950[K]"
python scripts/prepare_inputs.py model.mph --sweep "T_in=800[K]:50[K]:1000[K]" --paramfile-dir ./sweep/
python scripts/modify_mph_xml.py input.mph output.mph --set "T_in=950[K]"
python scripts/modify_mph_xml.py input.mph output.mph --from-json overrides.json
python scripts/modify_mph_xml.py input.mph --diff
python scripts/generate_java.py model.mph
python scripts/generate_java.py model.mph --output Model.java
python scripts/generate_java.py model.mph --class-name SteamReformer
See references/input_preparation.md for comsolbatch CLI and workflow details.
Module 3: MCP Connectivity
Check COMSOL environment and set up MCP server for Claude-controlled simulation.
python scripts/check_comsol.py
python scripts/check_comsol.py --json
See references/mcp_setup.md for server setup and references/mcp_tools.md for tool reference.
Module 4: 3D Morphology Edit
Edit mphtxt mesh and STL geometry files programmatically.
python scripts/edit_mphtxt_mesh.py mesh.mphtxt --info
python scripts/edit_mphtxt_mesh.py mesh.mphtxt --translate 0.1 0 0 -o out.mphtxt
python scripts/edit_mphtxt_mesh.py mesh.mphtxt --scale 2.0 -o out.mphtxt
python scripts/edit_mphtxt_mesh.py mesh.mphtxt --rotate 90 0 0 1 -o out.mphtxt
python scripts/edit_mphtxt_mesh.py mesh.mphtxt --mirror 1 0 0 -o out.mphtxt
python scripts/edit_stl.py model.stl --info
python scripts/edit_stl.py model.stl --translate 0.1 0 0 --scale 2 -o out.stl
python scripts/edit_stl.py model.stl --rotate 90 0 0 1 -o out.stl
python scripts/edit_stl.py model.stl --to-mphtxt out.mphtxt
See references/geometry_formats.md for format specifications.
Capabilities Matrix
| Capability | COMSOL Required | Script |
|---|
| Extract parameters/physics/materials | No | analyze_mph.py |
| Generate parameter files | No | prepare_inputs.py |
| Modify .mph parameters | No | modify_mph_xml.py |
| Generate Java API code | No | generate_java.py |
| Check COMSOL environment | No | check_comsol.py |
| Edit mphtxt mesh | No | edit_mphtxt_mesh.py |
| Edit STL geometry | No | edit_stl.py |
| Run simulations via MCP | Yes | (MCP server) |
| Compile/run Java models | Yes | (comsolbatch) |
Limitations
- Cannot read binary
.mphbin data (geometry coordinates inside .mph, mesh solutions)
- Cannot run simulations without COMSOL installation
- Cannot edit Parasolid geometry (.mphtxt geometry format is binary-encoded)
- Cannot edit STEP files without cadquery/OCP
- Password-protected .mph files cannot be analyzed