comsol-codex-mcp

comsol-codex-mcp

An MCP server that provides tools for reproducible COMSOL Multiphysics batch workflows, enabling AI agents to compile, run, and diagnose Java API model scripts with COMSOL.

Category
访问服务器

README

COMSOL Codex MCP

An MCP server and agent toolkit for reproducible COMSOL Multiphysics batch workflows.

This project is intentionally generic. It does not encode one specific COMSOL model. Instead, it gives AI agents a safe, auditable way to:

  • discover a local COMSOL installation;
  • compile Java API model scripts with comsolcompile;
  • run compiled classes with comsolbatch;
  • monitor and diagnose logs;
  • search COMSOL completion XML for Java API feature/property names;
  • collect lightweight result packages while excluding .mph, raw dumps, logs, and generated classes;
  • expose reusable COMSOL automation recipes to Codex/Claude-style agents through MCP tools.

Why This Exists

Several COMSOL MCP projects focus on GUI automation or Python MPh/mphserver workflows. This project focuses on the engineering loop that coding agents often need:

write Java API model -> compile -> batch run -> inspect log -> parse output -> package results

That loop is useful for long-running, reproducible simulation jobs where opening COMSOL Desktop is undesirable or impossible.

Install

python -m pip install -e .

To run as an MCP server:

python -m pip install -e ".[mcp]"
comsol-mcp-server

To use the standalone CLI:

comsol-tool find-install
comsol-tool search-feature ThermalContact
comsol-tool inspect-log path/to/batch.log

Documentation

MCP Tools

The server exposes:

Tool Purpose
comsol_find_install Locate comsolcompile, comsolbatch, and comsol
comsol_compile Compile a COMSOL Java API model
comsol_batch Run a compiled class with comsolbatch
comsol_tail_file Read the tail of a log/output file
comsol_inspect_log Detect common COMSOL errors and progress markers
comsol_search_feature Search physics.xml/common.xml for Java API hints
comsol_collect_outputs Zip lightweight scripts/summaries/CSV outputs
comsol_clean_generated List or remove generated class/status/recovery files
comsol_list_recipes List built-in workflow recipes
comsol_get_recipe Read a built-in workflow recipe

Example Agent Workflow

  1. Call comsol_find_install.
  2. Ask the model to generate or modify a Java API script.
  3. Call comsol_compile.
  4. If compilation fails, use the compiler output and comsol_search_feature.
  5. Call comsol_batch with a bounded timeout.
  6. If the run is slow or fails, call comsol_inspect_log.
  7. Parse model stdout with a project-specific parser.
  8. Call comsol_collect_outputs to create an uploadable result bundle.

COMSOL Setup

The install finder checks:

  • COMSOL_HOME
  • COMSOL_ROOT
  • PATH
  • common Windows locations such as C:\Program Files\COMSOL and E:\Program Files\COMSOL
  • common Linux locations such as /usr/local/comsol and /opt/comsol

If discovery fails, set:

COMSOL_HOME=/path/to/COMSOL63

On Windows PowerShell:

$env:COMSOL_HOME = "E:\Program Files\COMSOL\COMSOL63"

Safety Model

This toolkit is deliberately conservative:

  • it uses subprocess.run([...], shell=False);
  • it keeps compile/run operations explicit;
  • it separates stdout, stderr, and batch logs;
  • it excludes heavy/generated files from packages by default;
  • it provides diagnostics rather than hiding COMSOL failures.

You should still run it only on trusted COMSOL Java scripts. A COMSOL Java class can create, solve, and save models on your machine.

What This Is Not

  • It is not a replacement for COMSOL Desktop.
  • It is not a universal physics model generator.
  • It does not ship COMSOL, licenses, or proprietary documentation.
  • It does not guarantee that a generated Java API script is physically valid.

Related Work

Existing public projects include GUI-driven COMSOL MCP servers, MPh/mphserver-based MCP servers, and Pythonic COMSOL scripting interfaces. This project aims to complement them with a batch-first, Codex-friendly, reproducible Java API workflow.

Trademark Notice

COMSOL and COMSOL Multiphysics are trademarks or registered trademarks of COMSOL AB. This project is independent and unofficial. See NOTICE.md.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选