COMSOL Multiphysics MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/wjc9011/comsol-mcp.git
cd comsol-mcp
python -m pip install -e .
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add comsol-multiphysics -- node "<FULL_PATH_TO_COMSOL_MULTIPHYSICS_MCP>/dist/index.js"

Replace <FULL_PATH_TO_COMSOL_MULTIPHYSICS_MCP>/dist/index.js with the actual folder you prepared in step 1.

README.md

MCP Server for COMSOL Multiphysics simulation automation via AI agents.

COMSOL MCP Server

MCP Server for COMSOL Multiphysics simulation automation via AI agents.

English | 中文

Project Goal

Build a complete COMSOL MCP Server enabling AI agents (like Claude, opencode) to perform multiphysics simulations through the MCP protocol:

  1. Model Management - Create, load, save, version control
  2. Geometry Building - Blocks, cylinders, spheres, boolean operations
  3. Physics Configuration - Heat transfer, fluid flow, electrostatics, solid mechanics
  4. Meshing & Solving - Auto mesh, stationary/time-dependent studies
  5. Results Visualization - Evaluate expressions, export plots
  6. Knowledge Integration - Embedded guides + PDF semantic search

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/wjc9011/comsol-mcp.git
cd comsol-mcp

# Install dependencies
python -m pip install -e .

# Test server
python -m src.server

Building PDF Knowledge Base

# Install additional dependencies
pip install pymupdf chromadb sentence-transformers

# Build knowledge base
python scripts/build_knowledge_base.py

# Check status
python scripts/build_knowledge_base.py --status

Usage

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-mcp"
    }
  }
}

Code Structure

comsol_mcp/
├── opencode.json                    # MCP server config for opencode
├── pyproject.toml                   # Python project config
├── README.md                        # This file
│
├── 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
│   ├── 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
│
├── client_script/                   # Standalone modeling scripts (examples)
│   ├── create_chip_tsv_final.py     # Example: Chip thermal model
│   ├── create_micromixer_auto.py    # Example: Fluid flow simulation
│   ├── create_chip_thermal*.py      # Various chip thermal variants
│   ├── create_micromixer*.py        # Various micromixer variants
│   ├── visualize_*.py               # Result visualization scripts
│   ├── add_visualization.py         # Add plot groups to model
│   └── test_*.py                    # Integration tests
│
├── comsol_models/                   # Saved models (structured)
│   ├── chip_tsv_thermal/
│   │   ├── chip_tsv_thermal_20260216_*.mph
│   │   └── chip_tsv_thermal_latest.mph
│   └── micromixer/
│       └── micromixer_*.mph
│
└── tests/
    └── test_basic.py                # Unit tests

Available Tools (80+ total)

Session (4)

Tool Description
comsol_start Start local COMSOL client
comsol_connect Connect to remote server
comsol_disconnect Clear session
comsol_status Get session info

Model (9)

Tool Description
model_load Load .mph file
model_create Create empty model
model_save Save to file
model_save_version Save with timestamp
model_list List loaded models
model_set_current Set active model
model_clone Clone model
model_remove Remove from memory
model_inspect Get model structure

Parameters (5)

Tool Description
param_get Get parameter value
`p

Tools (14)

comsol_startStart local COMSOL client
comsol_connectConnect to remote server
comsol_disconnectClear session
comsol_statusGet session info
model_loadLoad .mph file
model_createCreate empty model
model_saveSave to file
model_save_versionSave with timestamp
model_listList loaded models
model_set_currentSet active model
model_cloneClone model
model_removeRemove from memory
model_inspectGet model structure
param_getGet parameter value

Environment Variables

HF_ENDPOINTHugging Face mirror endpoint for model downloads

Configuration

claude_desktop_config.json
{"mcpServers": {"comsol": {"command": "python", "args": ["-m", "src.server"], "cwd": "/path/to/comsol-mcp"}}}

Try it

Start a new COMSOL session and create an empty model.
Load the chip_tsv_thermal model and inspect its current structure.
Create a block geometry with dimensions 10mm x 10mm x 2mm.
Run a stationary study on the current model and export the results.
Search the knowledge base for troubleshooting steps regarding heat transfer physics.

Frequently Asked Questions

What are the key features of COMSOL Multiphysics?

Automated model management including creation, loading, and versioning.. Geometry building capabilities for blocks, cylinders, and spheres.. Physics configuration for heat transfer, fluid flow, and electrostatics.. Integrated PDF semantic search for physics guides and troubleshooting.. Async solving support with progress tracking for stationary and time-dependent studies..

What can I use COMSOL Multiphysics for?

Automating repetitive simulation workflows for thermal analysis of microchips.. Rapidly iterating through geometry variations in fluid flow simulations.. Integrating COMSOL documentation directly into the AI agent's reasoning process.. Managing version control for complex multiphysics model files..

How do I install COMSOL Multiphysics?

Install COMSOL Multiphysics by running: git clone https://github.com/wjc9011/comsol-mcp.git && cd comsol-mcp && python -m pip install -e .

What MCP clients work with COMSOL Multiphysics?

COMSOL Multiphysics works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep COMSOL Multiphysics docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare