COMSOL MCP Server
Allows AI agents to perform multiphysics simulations using COMSOL Multiphysics, including model management, geometry building, physics configuration, meshing, solving, and results visualization.
Click on "Install 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 ServerCreate a model and run a stationary solver."
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 Server
MCP Server for COMSOL Multiphysics simulation automation via AI agents.
Project Goal
Build a complete COMSOL MCP Server enabling AI agents (like Claude, opencode) to perform multiphysics simulations through the MCP protocol:
Model Management - Create, load, save, version control
Geometry Building - Blocks, cylinders, spheres, boolean operations
Physics Configuration - Heat transfer, fluid flow, electrostatics, solid mechanics
Meshing & Solving - Auto mesh, stationary/time-dependent studies
Results Visualization - Evaluate expressions, export plots
Knowledge Integration - Embedded guides + PDF semantic search
Related MCP server: pyNastran MCP Server
Requirements
COMSOL Multiphysics (version 5.x or 6.x)
Python 3.10+ (NOT Windows Store version)
Java runtime (required by MPh/COMSOL)
Installation
# Clone repository
git clone https://github.com/HBPEKING-TKS/mcp_server.git
cd comsol-multiphysics-mcp
# Install dependencies
python -m pip install -e .
# Test server
python -m src.serverBuilding PDF Knowledge Base
# Install additional dependencies
pip install pymupdf chromadb sentence-transformers
# Build knowledge base (requires COMSOL PDF documentation)
python scripts/build_knowledge_base.py
# Check status
python scripts/build_knowledge_base.py --statusUsage
Option 1: With opencode
Create opencode.json in project root:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"comsol": {
"type": "local",
"command": ["python", "-m", "src.server"],
"enabled": true,
"environment": {
"HF_ENDPOINT": "https://hf-mirror.com"
},
"timeout": 30000
}
}
}Option 2: With Claude Desktop
{
"mcpServers": {
"comsol": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/comsol-multiphysics-mcp"
}
}
}Code Structure
comsol-multiphysics-mcp/
├── opencode.json # MCP server config for opencode
├── pyproject.toml # Python project config
├── README.md # This file
├── LICENSE # MIT License
│
├── src/
│ ├── server.py # MCP Server entry point
│ ├── tools/
│ │ ├── session.py # COMSOL session management (start/stop/status)
│ │ ├── model.py # Model CRUD + versioning
│ │ ├── parameters.py # Parameter management + sweeps
│ │ ├── geometry.py # Geometry creation (block/cylinder/sphere)
│ │ ├── physics.py # Physics interfaces + boundary conditions
│ │ ├── mesh.py # Mesh generation
│ │ ├── study.py # Study creation + solving (sync/async)
│ │ └── results.py # Results evaluation + export
│ ├── resources/
│ │ └── model_resources.py # MCP resources (model tree, parameters)
│ ├── knowledge/
│ │ ├── embedded.py # Embedded physics guides + troubleshooting
│ │ ├── retriever.py # PDF vector search retriever
│ │ ├── pdf_processor.py # PDF chunking + embedding
│ │ └── prompts/ # Reference docs (API, physics, workflow)
│ ├── async_handler/
│ │ └── solver.py # Async solving with progress tracking
│ └── utils/
│ └── versioning.py # Model version path management
│
├── scripts/
│ └── build_knowledge_base.py # Build PDF vector database
│
├── comsol_models/ # Saved models (structured)
│ └── {model_name}/
│ ├── {model_name}_{timestamp}.mph
│ └── {model_name}_latest.mph
│
└── tests/
└── test_basic.py # Unit testsAvailable Tools (80+ total)
Session (4)
Tool | Description |
| Start local COMSOL client |
| Connect to remote server |
| Clear session |
| Get session info |
Model (9)
Tool | Description |
| Load .mph file |
| Create empty model |
| Save to file |
| Save with timestamp |
| List loaded models |
| Set active model |
| Clone model |
| Remove from memory |
| Get model structure |
Parameters (5)
Tool | Description |
| Get parameter value |
| Set parameter |
| List all parameters |
| Setup parametric sweep |
| Get/set description |
Geometry (14)
Tool | Description |
| List geometry sequences |
| Create geometry sequence |
| Add rectangular block |
| Add cylinder |
| Add sphere |
| Union objects |
| Subtract objects |
| Import CAD file |
| Build geometry |
... | ... |
Physics (16)
Tool | Description |
| Add Electrostatics |
| Add Solid Mechanics |
| Add Heat Transfer |
| Add Laminar Flow |
| Configure boundary condition |
| Add coupling |
| Configure heat boundaries |
| Configure flow boundaries |
... | ... |
Study & Solving (8)
Tool | Description |
| List studies |
| Solve synchronously |
| Solve in background |
| Get progress |
| Cancel solving |
| Wait for completion |
Results (9)
Tool | Description |
| Evaluate expression |
| Evaluate scalar |
| Get time steps |
| Get sweep values |
| Export data |
| Export plot image |
Knowledge (8)
Tool | Description |
| Get documentation |
| List available docs |
| Physics quick guide |
| Troubleshooting help |
| Best practices |
| Search PDF docs |
| PDF search status |
| List PDF modules |
Key Technical Discoveries
MPh Library API Patterns
# Access Java model via property (not callable)
jm = model.java # NOT model.java()
# Create component with True flag
comp = jm.component().create('comp1', True)
# Create 3D geometry
geom = comp.geom().create('geom1', 3)
# Boundary condition with selection
bc = physics.create('inl1', 'InletBoundary')
bc.selection().set([1, 2, 3])
bc.set('U0', '1[mm/s]')Boundary Condition Property Names
Physics | Condition | Property |
Heat Transfer | HeatFluxBoundary |
|
Heat Transfer | TemperatureBoundary |
|
Heat Transfer | ConvectiveHeatFlux |
|
Laminar Flow | InletBoundary |
|
Laminar Flow | OutletBoundary |
|
Model Versioning
Models are saved with structured paths:
./comsol_models/{model_name}/{model_name}_{timestamp}.mph
./comsol_models/{model_name}/{model_name}_latest.mphMCP Resources
URI | Description |
| Session information |
| Model tree structure |
| Model parameters |
| Physics interfaces |
License
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/HBPEKING-TKS/mcp_server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server