comsol-mcp

comsol-mcp

MCP server for visible COMSOL automation that attaches to a running COMSOL Multiphysics Server, enabling shared model state with the Desktop GUI for collaborative modeling.

Category
访问服务器

README

COMSOL MCP

AI-driven MCP server for COMSOL with a visible Desktop client workflow.

comsol-mcp is built for the workflow where:

  • you manually start COMSOL Multiphysics Server
  • COMSOL Desktop connects to that server as a visual client
  • an MCP client attaches to the same server-side model
  • modeling changes remain visible instead of running as a black-box batch job

This repository is the new mainline for visible COMSOL automation in this codebase. The old batch-oriented route is now a legacy reference only.

Why This Project Exists

Many COMSOL automation flows are powerful but opaque. They can compile Java, run batch jobs, or drive generic server-side simulations, but they do not always let you watch the model evolve in the Desktop GUI.

comsol-mcp focuses on a different goal:

  • visible GUI changes
  • shared server-side model state
  • no Desktop-side polling bridge
  • no GUI automation layer
  • no black-box batch-only workflow

Core Workflow

This project uses an attach-first workflow:

  1. Start COMSOL Multiphysics Server manually.
  2. Note the real listening port from the server console.
  3. Connect COMSOL Desktop to that same port.
  4. Import the server-side model into Desktop if needed.
  5. Attach MCP to the same server with server_connect(host, port).
  6. Create or load the working model.
  7. Use MCP tools to modify the shared server-side model.
  8. Watch the same model update in COMSOL Desktop.

See the workflow guide for the full version.

Quick Start

Prerequisites

  • Windows with COMSOL installed locally
  • A valid COMSOL license
  • Python 3.10 or newer
  • A manually started COMSOL Multiphysics Server

Install

From source:

git clone <your-repo-url> comsol-mcp
cd comsol-mcp
python -m pip install -e .

Set environment variables:

$env:COMSOL_ROOT = "C:\Program Files\COMSOL\COMSOL63\Multiphysics"
$env:COMSOL_SERVER_MCP_HOME = "$PWD\comsol-server-home"

Start the MCP server:

python -m comsol_mcp.mcp_server

Or use the helper script:

.\scripts\start_comsol_mcp.ps1 -Python python -ComsolRoot "C:\Program Files\COMSOL\COMSOL63\Multiphysics" -McpHome "$PWD\comsol-server-home"

MCP Config Example

See:

Minimal Visible Demo

server_connect("localhost", <actual_port>)
model_create("VisibleServerModel")
ensure_component("comp1", 2)
ensure_geometry("comp1", "geom1", 2)
ensure_mesh("comp1", "mesh1")
create_feature("comp1", "geom1", "r1", "Rectangle", "[{\"name\":\"size\",\"values\":[\"60[mm]\",\"30[mm]\"]},{\"name\":\"pos\",\"values\":[\"-30[mm]\",\"-15[mm]\"]}]", true)
run_feature("mesh", "mesh1", "comp1")

Desktop should show the same geometry because Desktop and MCP share the same server-side model.

See examples/attach_first_demo.md for the same flow in document form.

Tool Surface

Current tools:

  • server_info()
  • server_start(...)
  • server_connect(host, port, model_name="")
  • server_disconnect(shutdown_server=false)
  • model_create(name="Server Model")
  • model_load(path)
  • model_tree()
  • get_parameters()
  • set_parameters(parameters_json)
  • ensure_component(component="comp1", dimension=2)
  • ensure_geometry(component="comp1", geometry="geom1", dimension=2)
  • ensure_mesh(component="comp1", mesh="mesh1")
  • create_feature(component, geometry, tag, feature_type, properties_json="[]", run_geometry=false)
  • update_feature(component, geometry, tag, properties_json, run_geometry=false)
  • delete_feature(component, geometry, tag, run_geometry=false)
  • run_feature(collection, tag, component="comp1")
  • run_study(study_tag="")
  • save_model(path="")

The modeling tool surface is intentionally stable. This repository cleanup does not rename or remove these tools.

Recommended Entry Point

The recommended entrypoint is:

server_connect("localhost", <actual_port>)

server_start() is still available, but it is now an advanced fallback. Use it only when you want MCP to own the COMSOL server lifecycle and accept that COMSOL may choose a different listening port automatically.

Known Limitations

  • COMSOL Desktop may not automatically display the server-side model after a successful connection; you may need to import or switch to the existing server model.
  • server_connect() can succeed while no current working model is selected; in that case use model_create() or model_load().
  • The server console output and the actual listening port should always be verified against the real active listener.
  • Desktop graphics may require a light refresh after server-side model changes.

See the troubleshooting guide.

How This Differs From Other MCPs

Versus abaqus-mcp-server

abaqus-mcp-server is a GUI scripting / GUI automation style project. It works with an already running GUI and uses GUI automation techniques to trigger actions.

comsol-mcp does not use pywinauto-style GUI automation for COMSOL. Instead, it attaches directly to COMSOL Multiphysics Server and drives the same server-side model that Desktop visualizes.

Versus generic COMSOL automation MCPs

Public COMSOL MCP listings often emphasize solver breadth, mesh generation, physics setup, and parametric sweep coverage.

This project emphasizes a different value proposition:

  • attach-first
  • visible Desktop workflow
  • non-black-box modeling
  • shared model state between Desktop and MCP

It is not just "another COMSOL automation MCP"; it is specifically about making the workflow visible and collaborative with the Desktop client.

Versus the old batch route

The old batch route used:

  • comsolcompile
  • comsolbatch

That route is still useful for offline jobs, but it is no longer the public identity of this project. In this repository, it is treated as a legacy reference rather than the mainline.

See docs/differences.md for a fuller comparison.

Legacy / Previous Batch Route

An earlier internal comsol-mcp route in this codebase was batch-oriented and wrapped comsolcompile plus comsolbatch. That legacy route is intentionally not the public face of this repository.

This repository focuses on:

  • COMSOL Multiphysics Server
  • Desktop as a visual client
  • MCP attach to the same model

Attribution

  • Built on top of MPh
  • Inspired by COMSOL client-server workflows and related MCP explorations
  • Not affiliated with COMSOL
  • Does not include COMSOL binaries or proprietary assets

License

MIT. See LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选