MCP Servers

A collection of Model Context Protocol servers, templates, tools and more.

C
Comsol Multiphysics MCP

Local MCP server for COMSOL modeling workflows, validation, and RAG-assisted multiphysics automation.

Created 5/14/2026
Updated about 4 hours ago
Repository documentation and setup instructions

COMSOL Multiphysics MCP

COMSOL Multiphysics MCP is a local MCP server for COMSOL Multiphysics workflows. It combines mph automation, COMSOL Desktop inspection, guided modeling workflows, validation tools, result extraction, and RAG-assisted documentation retrieval behind a single MCP interface.

中文文档: README.zh-CN.md

This is an unofficial local automation project. It is not affiliated with, endorsed by, or supported by COMSOL AB.

Features

  • COMSOL automation: create, load, inspect, save, and solve COMSOL models through the Python mph backend.
  • Desktop assistance: inspect COMSOL Desktop windows, capture screenshots, use Java Shell fallback actions, and sync between GUI and mph sessions.
  • Modeling toolchain: parameters, components, geometry, selections, materials, physics, boundaries, mesh, studies, solving, plots, and exported results.
  • Guided workflows: built-in templates for common multiphysics tasks, next-step suggestions, step validation, and model completeness diagnostics.
  • RAG-assisted modeling: local ChromaDB retrieval over authorized COMSOL documentation, with module-aware search and modeling-context extraction.
  • MCP integration: stdio MCP server for Claude Desktop and other MCP-compatible clients.

Repository Layout

.
├── src/comsol_agent_mcp/      # MCP server and core implementation
│   ├── server.py              # FastMCP tool entrypoint
│   ├── config.py              # Environment variables and local paths
│   ├── backends/              # mph and COMSOL Desktop backends
│   ├── tools/                 # Modeling, solving, plotting, GUI tools
│   ├── workflows/             # Workflow templates and step manager
│   ├── validators/            # Model setup and result validation
│   ├── knowledge/             # Embedded docs and RAG retrieval
│   └── assistants/            # Natural-language modeling assistant
├── scripts/                   # Knowledge-base utilities
├── tests/                     # Automated tests
├── knowledge_base/            # Placeholder docs for the local RAG index
├── env.local.example          # Local configuration template
├── start-comsol-mcp.cmd       # Windows launcher
└── pyproject.toml             # Python package metadata

Paths written as ./path/ are relative to the repository root. For example, if the repository is cloned to D:\path\to\COMSOL_MCP, then ./src/ means D:\path\to\COMSOL_MCP\src.

Installation

Use Python 3.10+ and install the project from the repository root:

python -m pip install -e .[dev]

Create local settings:

Copy-Item ./env.local.example ./env.local

Edit env.local for your COMSOL installation, embedding service, document paths, output paths, and cache paths. Keep real API keys and private machine paths only in env.local.

Start the MCP server:

python -m comsol_agent_mcp.server

On Windows you can also run:

./start-comsol-mcp.cmd

MCP Client Configuration

Example stdio configuration:

{
  "mcpServers": {
    "comsol-multiphysics-mcp": {
      "command": "<python>",
      "args": ["-m", "comsol_agent_mcp.server"],
      "cwd": "<repo-root>"
    }
  }
}

Windows example:

{
  "mcpServers": {
    "comsol-multiphysics-mcp": {
      "command": "D:\\path\\to\\COMSOL_MCP\\conda-envs\\comsol-mcp\\python.exe",
      "args": ["-m", "comsol_agent_mcp.server"],
      "cwd": "D:\\path\\to\\COMSOL_MCP"
    }
  }
}

If you do not use the optional local conda-envs/comsol-mcp environment, point command to your active virtual environment's python.exe or to python.

Workflows

Workflows are lightweight modeling guides kept in the current MCP server process. They do not replace the COMSOL model; they track the selected template, goal, current step, suggested tools, and validation hints. Restarting the server clears the active workflow, so call workflow_start again after a restart.

Built-in templates:

  • general
  • electrostatics
  • heat_transfer
  • fluid_flow
  • solid_mechanics

Shared step chain:

requirements -> parameters -> component -> geometry -> geometry_build -> materials -> physics -> boundaries -> mesh -> study -> solve -> results -> save_version

Typical sequence:

workflow_list_templates
workflow_start
workflow_next_step
run the recommended modeling tools
workflow_validate_current_step
repeat next_step/validate until complete
workflow_diagnose_model

For an electrostatic capacitor model, the workflow typically recommends setting parameters such as V0, epsr, gap, and electrode_radius, creating geometry, assigning materials, adding Electrostatics, applying Terminal/Ground/ElectricPotential boundaries, building mesh, solving a stationary study, evaluating expressions such as es.V, es.normE, es.intWe, and saving a versioned model.

RAG Knowledge Base

The RAG pipeline can build a local ChromaDB index from the public COMSOL module tutorials/manuals used by this project. The author's current build was generated from a pre-cleaned documentation package covering many modules, with about 108 PDFs and 72k chunks.

The difficult part is the PDF-to-RAG preparation step: the preprocessing workflow can use the open-source MinerU project for structured PDF extraction, and deploying/running that stack is heavier than using the MCP server itself. For most users, the recommended path is to download the prepared Release assets first, then rebuild only when they need to update the corpus.

The generated PDFs and vector database are not tracked in Git history because they are large binary/data assets:

  • pdf/ is about 0.52 GB in this workspace;
  • knowledge_base/ is about 1.34 GB, including a chroma.sqlite3 file larger than GitHub's normal 100 MiB Git file limit;
  • storing these files in normal Git history makes cloning slow and can cause GitHub push failures.

Recommended sharing layout:

  • keep source code, scripts, tests, and metadata in the GitHub repository;
  • publish pdf/ and knowledge_base/ as GitHub Release assets, for example comsol-docs-pdf.zip and comsol-rag-knowledge-base.zip;
  • keep knowledge_base/README.md and knowledge_base/manifest.example.json in Git so users can understand the expected local database shape.

Prepare Release assets locally:

./scripts/package_release_assets.ps1

This creates zip files and SHA256 checksums under ./release_assets/. Upload those files to a GitHub Release such as data-v1.

Restore downloaded assets:

Expand-Archive ./comsol-docs-pdf.zip ./pdf -Force
Expand-Archive ./comsol-rag-knowledge-base.zip ./knowledge_base -Force
python ./scripts/build_knowledge_base.py --status

Build from PDFs under ./pdf/:

python ./scripts/build_knowledge_base.py --rebuild

Build from a cleaned package containing chunks.jsonl:

python ./scripts/build_knowledge_base.py --rebuild --from-package <rag_embedding_package>

Check status:

python ./scripts/build_knowledge_base.py --status

Typical embedding settings:

DASHSCOPE_API_KEY=replace-with-your-dashscope-api-key
COMSOL_AGENT_EMBEDDING_MODEL=text-embedding-v4
COMSOL_AGENT_EMBEDDING_DIMENSION=1024
COMSOL_AGENT_EMBEDDING_ENDPOINT=https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings

Main MCP Tools

  • Backend/session: backend_status, backend_set_default, mph_start, mph_connect, mph_status, mph_disconnect
  • Model/parameters: model_create, model_load, model_save, model_save_version, model_inspect, param_set, param_list
  • Geometry/materials/physics: geometry_create, geometry_add_block, geometry_add_cylinder, geometry_build, material_create_common, physics_add, physics_add_electrostatics, physics_add_heat_transfer
  • Boundaries/mesh/study: boundary_get_presets, boundary_add_condition, boundary_add_preset, mesh_create, mesh_build, study_create_stationary, study_solve
  • Results/plots: results_evaluate, results_global_evaluate, results_plots_list, plot_export_image, plot_export_geometry_view
  • Desktop: gui_status, gui_diagnose, gui_open_model, gui_ensure_java_shell, gui_execute_java_shell, gui_capture_window, gui_capture_graphics_panel
  • Workflows: workflow_list_templates, workflow_start, workflow_next_step, workflow_validate_current_step, workflow_diagnose_model
  • Validation/RAG/assistant: model_validate_all, physics_validate_setup, boundary_validate_conditions, mesh_validate, rag_status, rag_build, rag_search, modeling_assist

Tests

python -m pytest

For a quick documentation/workflow smoke test:

python -m pytest tests/test_workflows.py tests/test_rag_status.py

Acknowledgements

This project was developed with reference to ideas and implementation patterns from:

The local reference/ directory, if present in the author's workspace, is only used for comparison during development and is not part of the published repository.

Notes

  • COMSOL and COMSOL Multiphysics are trademarks or registered trademarks of COMSOL AB.
  • This repository does not include COMSOL software, official COMSOL documentation, .mph model files, generated simulation results, private API keys, or the author's local RAG database.
  • COMSOL Desktop tools require Windows interactive desktop access and an installed COMSOL Desktop.
  • Java Shell execution is restricted by default to model. COMSOL Java API statements unless allow_non_model_code=true is explicitly set.
Quick Setup
Installation guide for this server

Install Package (if required)

uvx comsol-multiphysics-mcp

Cursor configuration (mcp.json)

{ "mcpServers": { "suzy-sa-comsol-multiphysics-mcp": { "command": "uvx", "args": [ "comsol-multiphysics-mcp" ] } } }