COMSOL MCP Serverのロゴ

COMSOL MCP Server

コミュニティ
wjc9011

MCP Server for COMSOL Multiphysics simulation automation via AI agents.

公開者wjc9011
リポジトリCOMSOL_Multiphysics_MCP
言語Python
フォーク
77
スター
774
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    COMSOL MCP Serverは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには774件のスターと77件のフォークがあります。

COMSOL MCP Server

MCP Server for COMSOL Multiphysics simulation automation via AI agents.

English | 中文

Star History

GitHub stars

Star History Chart

Publication and Citation

The research paper describing COMSOL-MCP is available in Neurocomputing:

Naiyin Zhang and Junchao Wang, “COMSOL-MCP: An open-source model context protocol interface for AI-assisted multiphysics simulation,” Neurocomputing, vol. 703, article 134481, 2026.

Publisher page: ScienceDirect

If COMSOL-MCP contributes to your research, please cite the paper:

bibtex
@article{Zhang2026COMSOLMCP,
  title   = {COMSOL-MCP: An Open-Source Model Context Protocol Interface for AI-Assisted Multiphysics Simulation},
  author  = {Zhang, Naiyin and Wang, Junchao},
  journal = {Neurocomputing},
  volume  = {703},
  pages   = {134481},
  year    = {2026},
  doi     = {10.1016/j.neucom.2026.134481},
  url     = {https://doi.org/10.1016/j.neucom.2026.134481}
}

Citation guidance

  • Cite the paper when referring to the COMSOL-MCP method, architecture, capabilities, or evaluation.
  • If you use or modify the software, cite both the paper and the repository. Use GitHub’s Cite this repository menu, which is backed by CITATION.cff.
  • For reproducibility, identify the exact release tag or commit used and include the repository URL and access date in your data/code availability statement.

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

bash
# Clone repository
git clone https://github.com/wjc9011/COMSOL_Multiphysics_MCP.git
cd COMSOL_Multiphysics_MCP

# Install dependencies
python -m pip install -e .

# Test server
python -m src.server

Building PDF Knowledge Base

bash
# 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:

json
{
  "$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

json
{
  "mcpServers": {
    "comsol": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/COMSOL_Multiphysics_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 (100+ total)

Session (4)

ToolDescription
comsol_startStart local COMSOL client
comsol_connectConnect to remote server
comsol_disconnectClear session
comsol_statusGet session info

Model (9)

ToolDescription
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

Parameters (5)

ToolDescription
param_getGet parameter value
param_setSet parameter
param_listList all parameters
param_sweep_setupSetup parametric sweep
param_descriptionGet/set description

Geometry (16)

ToolDescription
geometry_listList geometry sequences
geometry_createCreate geometry sequence
geometry_add_featureAdd generic feature
geometry_add_blockAdd rectangular block
geometry_add_cylinderAdd cylinder
geometry_add_sphereAdd sphere
geometry_add_rectangleAdd 2D rectangle
geometry_add_circleAdd 2D circle
geometry_boolean_unionUnion objects
geometry_boolean_differenceSubtract objects
geometry_importImport CAD file
geometry_buildBuild geometry
geometry_list_featuresList features
geometry_get_boundariesGet boundary numbers
geometry_create_box_selectionCreate a named selection by position
geometry_create_side_selectionsCreate left/right/top/bottom selections

Physics (28)

ToolDescription
physics_listList physics interfaces
physics_get_availableAvailable physics types
physics_addAdd generic physics
physics_add_electrostaticsAdd Electrostatics
physics_add_solid_mechanicsAdd Solid Mechanics
physics_add_heat_transferAdd Heat Transfer
physics_add_laminar_flowAdd Laminar Flow
physics_add_acousticsAdd a geometry-based acoustic interface by COMSOL type
physics_add_pressure_acousticsAdd Pressure Acoustics
physics_add_coefficient_form_pdeAdd Coefficient Form PDE
physics_add_general_form_pdeAdd General Form PDE
physics_add_weak_form_pdeAdd Weak Form PDE
physics_configure_boundaryConfigure boundary condition
physics_configure_acoustic_boundaryConfigure one acoustic boundary condition
physics_setup_acoustic_boundariesConfigure multiple acoustic boundary conditions
physics_configure_pde_boundaryConfigure one PDE boundary condition
physics_setup_pde_boundariesConfigure multiple PDE boundary conditions
physics_get_acoustic_boundary_conditionsList common acoustic boundary feature types
physics_get_pde_boundary_conditionsList common PDE boundary feature types
physics_set_materialAssign material
physics_list_featuresList physics features
physics_removeRemove physics
multiphysics_addAdd coupling
physics_interactive_setup_heatInteractive heat BC setup
physics_setup_heat_boundariesConfigure heat boundaries
physics_interactive_setup_flowInteractive flow BC setup
physics_boundary_selectionGeneric boundary setup

Electrochemistry (10)

Battery, fuel cell, electrodeposition, and corrosion support backed by a type registry verified against a live COMSOL 6.3 session (26 interfaces, 600+ feature/subfeature types). A complete worked example — an 18650 cell 1C constant-current discharge — is included in src/knowledge/prompts/electrochemistry.md; call docs_get("electrochemistry") to retrieve it at runtime.

ToolDescription
electrochemistry_get_interfacesList verified interface types (battery, current distribution, corrosion, ...)
electrochemistry_get_feature_typesList verified feature types of an interface with dimensions
electrochemistry_add_interfaceAdd a verified interface (e.g. LithiumIonBatteryMPH, LumpedBattery)
electrochemistry_list_featuresInspect features with actual COMSOL types (getType())
electrochemistry_add_featureCreate a feature, incl. subfeatures via parent_feature
electrochemistry_set_feature_selectionAssign domains/boundaries to an existing feature
electrochemistry_set_feature_propertiesSet feature properties (rejected names reported)
electrochemistry_list_feature_propertiesAsk COMSOL for a feature's valid property names
electrochemistry_list_interface_propertiesRead interface-level property groups (e.g. BatterySettings)
electrochemistry_set_interface_propertiesConfigure interface-level settings (capacity, SOC, current, ...)

Mesh (4)

ToolDescription
mesh_listList mesh sequences
mesh_create_sequenceCreate a mesh sequence
mesh_createGenerate mesh
mesh_infoGet mesh statistics

Study & Solving (8)

ToolDescription
study_listList studies
study_solveSolve synchronously
study_solve_asyncSolve in background
study_get_progressGet progress
study_cancelCancel solving
study_waitWait for completion
solutions_listList solutions
datasets_listList datasets

Results (9)

ToolDescription
results_evaluateEvaluate expression
results_global_evaluateEvaluate scalar
results_inner_valuesGet time steps
results_outer_valuesGet sweep values
results_export_dataExport data
results_export_imageExport plot image
results_exports_listList export nodes
results_plots_listList plot nodes

Knowledge (8)

ToolDescription
docs_getGet documentation
docs_listList available docs
physics_get_guidePhysics quick guide
troubleshootTroubleshooting help
modeling_best_practicesBest practices
pdf_searchSearch PDF docs
pdf_search_statusPDF search status
pdf_list_modulesList PDF modules

Example Cases

Case 1: Chip Thermal Model with TSV

3D thermal analysis of a silicon chip with Through-Silicon Via (TSV).

Geometry: 60×60×5 µm chip, 5 µm diameter TSV hole, 10×10 µm heat source

python
# Key steps:
# 1. Create chip block and TSV cylinder
# 2. Boolean difference (subtract TSV from chip)
# 3. Add Silicon material (k=130 W/m·K)
# 4. Add Heat Transfer physics
# 5. Set heat flux on top, temperature on bottom
# 6. Solve and evaluate temperature distribution

Script: client_script/create_chip_tsv_final.py

Run:

bash
cd /path/to/COMSOL_Multiphysics_MCP
python client_script/create_chip_tsv_final.py

Results: Temperature rise from ambient with heat flux of 1 MW/m²

Case 2: Micromixer Fluid Flow

3D laminar flow simulation in a microfluidic channel.

Geometry: 600×100×50 µm rectangular channel

python
# Key steps:
# 1. Create rectangular channel block
# 2. Add water material (ρ=1000 kg/m³, μ=0.001 Pa·s)
# 3. Add Laminar Flow physics
# 4. Set inlet velocity (1 mm/s), outlet pressure
# 5. Add Transport of Diluted Species for mixing
# 6. Solve and evaluate velocity profile

Script: client_script/create_micromixer_auto.py

Run:

bash
cd /path/to/COMSOL_Multiphysics_MCP
python client_script/create_micromixer_auto.py

Results: Velocity distribution, concentration mixing profile

Model Versioning

Models are saved with structured paths:

./comsol_models/{model_name}/{model_name}_{timestamp}.mph
./comsol_models/{model_name}/{model_name}_latest.mph

Example:

./comsol_models/chip_tsv_thermal/chip_tsv_thermal_20260216_140514.mph
./comsol_models/chip_tsv_thermal/chip_tsv_thermal_latest.mph

Key Technical Discoveries

1. mph Library API Patterns

python
# 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)

# Create physics with geometry reference
physics = comp.physics().create('spf', 'LaminarFlow', 'geom1')

# Boundary condition with selection
bc = physics.create('inl1', 'InletBoundary')
bc.selection().set([1, 2, 3])
bc.set('U0', '1[mm/s]')

2. Boundary Condition Property Names

PhysicsConditionProperty
Heat TransferHeatFluxBoundaryq0
Heat TransferTemperatureBoundaryT0
Heat TransferConvectiveHeatFluxh, Text
Laminar FlowInletBoundaryU0, NormalInflowVelocity
Laminar FlowOutletBoundaryp0
Pressure AcousticsSoundHardNo additional property
Pressure AcousticsSoundSoftNo additional property
Pressure AcousticsPressurep0
Pressure AcousticsImpedanceZn
Pressure AcousticsNormalAccelerationnacc
Pressure AcousticsNormalVelocitynvel
Pressure AcousticsPlaneWaveRadiationNo additional property
Pressure AcousticsSphericalWaveRadiationNo additional property
PDEDirichletBoundaryr
PDEFluxBoundaryg, q
PDEZeroFluxBoundaryNo additional property
PDEWeakContributionweak
PDEPeriodicConditionNo additional property

3. Client Session Limitation

The mph library creates a singleton COMSOL client. Only one Client can exist per Python process:

python
# This is handled in session.py - client is kept alive and models are cleared
client.clear()  # Clear models instead of full disconnect

4. Offline Embedding Model

PDF search supports offline operation with local HuggingFace cache:

bash
# Set mirror for China
export HF_ENDPOINT=https://hf-mirror.com

Development Status

PhaseDescriptionStatus
1Basic framework + Session + ModelDone
2Parameters + Solving + ResultsDone
3Geometry + Physics + MeshDone
4Embedded knowledge + Tool docsDone
5PDF vector retrievalDone
6Integration testsIn Progress

Next Steps

  1. Complete Phase 6 - Full integration test with proper boundary conditions
  2. Visualization Export - Generate PNG images from plot groups
  3. LSP Warnings - Fix type hints in physics.py
  4. More Examples - Add electrostatics, solid mechanics cases
  5. Error Handling - Improve error messages and recovery

Resources

URIDescription
comsol://session/infoSession information
comsol://model/{name}/treeModel tree structure
comsol://model/{name}/parametersModel parameters
comsol://model/{name}/physicsPhysics interfaces

License

MIT

インストール

TypingMind
{
  "mcpServers": {
    "comsol-multiphysics-mcp": {
      "command": "python",
      "args": [
        "-m",
        "src.server"
      ]
    }
  }
}

COMSOL MCP ServerのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度COMSOL MCP Serverに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

COMSOL MCP Serverをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. COMSOL MCP ServerのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "comsol-multiphysics-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてCOMSOL MCP ServerのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. COMSOL MCP ServerのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
COMSOL MCP Serverを使ってこのタスクを手伝ってもらえますか?
COMSOL MCP Server
はい、読みました。
COMSOL MCP Serverで調べた結果をお伝えします。

よくある質問

COMSOL MCP Server MCPサーバーは何に使いますか?

COMSOL MCP Serverは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでCOMSOL MCP Server MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでCOMSOL MCP Serverを利用できます。

TypingMindでCOMSOL MCP Server MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。COMSOL MCP Serverを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

COMSOL MCP Server MCPをTypingMindに接続するにはどうすればよいですか?

COMSOL MCP ServerはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでCOMSOL MCP Server MCPのどのようなツールを利用できますか?

COMSOL MCP ServerはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

COMSOL MCP Server MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。COMSOL MCP Serverで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇