Skip to main content
Glama
ANSYS MCP Server

ANSYS MCP Server

by Bettertoo2

ANSYS MCP Local Server

❗本项目目前处于测试阶段

面向 ANSYS 2024 R2 的本地 stdio MCP 服务,覆盖 Fluent、Mechanical 和 PyAnsys Geometry,并内置 Fluent MCP-to-TUI journal 记录。

主要改进

  • 所有失败返回 isError=true、稳定错误码和恢复建议。

  • 每个工具同时返回文本与 structuredContent。

  • 连接现有 GUI 与 MCP 自行启动的实例采用不同生命周期策略。

  • ANSYS 同步调用在线程中执行,并按产品会话串行化。

  • Mechanical 对空模型返回分层 readiness,不再把集合越界当作状态。

  • 网格方法、载荷方向和单位均进入实际 IronPython 脚本。

  • 原始 TUI/IronPython 需要 confirm_unsafe=true。

  • Fluent journal 只记录成功执行的操作,且每个新会话自动清空历史。

  • 提供 Pydantic 输入约束、MCP annotations、输出 schema 和单元测试。

Related MCP server: Mechanical MCP Server

安装

建议使用 Python 3.11-3.13:

cd D:\build\ansys-mcp
py -3.13 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[test]"

确认 ANSYS 路径:

$env:AWP_ROOT242 = "C:\Program Files\ANSYS Inc\v242"

注册到 Codex:

.\scripts\install_codex.ps1 -InstallSkill

注册到 Claude Code:

.\scripts\install_claude.ps1 -InstallSkill

安装脚本在目标 MCP 或 skill 已存在时会停止,不会自动删除或覆盖。

启动与检查

直接启动 stdio 服务:

.\.venv\Scripts\python.exe -u .\server.py

运行测试:

.\.venv\Scripts\python.exe -m pytest

Mechanical GUI 连接

  1. 在 Workbench 中双击分析系统的 Model 单元并等待模型树加载。

  2. 打开 Mechanical 的 Scripting 窗口。

  3. 执行 scripts/mechanical_start_grpc.py。

  4. 使用返回端口调用 mechanical_launch。

连接结果中的关键字段为:

{
  "transport_connected": true,
  "scripting_ready": true,
  "project_open": true,
  "model_available": true,
  "analysis_count": 1
}

如果只有 transport 为 true,应先打开 Model 单元,而不是继续调用网格或求解工具。

生命周期规则

  • 无端口调用 *_launch:MCP 启动实例,*_exit 会关闭它。

  • 指定端口连接:MCP 仅附加,*_exit 默认只断开本地句柄。

  • 只有显式传入 shutdown_attached=true 才会关闭附加的 Fluent/Mechanical。

  • 已有活动会话时重新连接需要 replace=true。

新增工具

mechanical_get_mesh_settings 只读返回全局网格尺寸、物理与求解器偏好、 自适应尺寸、增长率、曲率以及节点/单元计数等当前版本可读取属性。

Skill 联动

完整 skill 位于 skills/ansys-fluent-tui-guide。服务端映射实现在 ansys_mcp/tui_mapper.py,不依赖把 skill Python 文件加入 sys.path,因此 skill 文档更新不会破坏 MCP 协议进程。fluent_get_script 返回 journal, fluent_get_mapping_report 返回结构化历史。报告中的 reproducible=false 或非空 unmapped_operations 表示 journal 是 partial,不能宣称完整复现; 当前材料设置和 UDF 加载/挂接会被明确记录为未映射。

安全说明

mechanical_script 和 fluent_tui 可以执行任意产品脚本,属于高风险工具。 高层工具仍可能修改或求解当前模型;执行前应确认连接的是正确实例,并保留工程副本。

远程 Fluent 附加默认禁止。非回环地址必须同时设置 allow_remote=true、 allow_insecure_remote=true 并提供密码。该路径使用不安全 gRPC,仅应用于可信网络; 优先通过安全隧道映射到本机回环地址。

兼容性

依赖范围锁定到本项目验证过的 MCP/PyAnsys 次版本。ANSYS 产品 API 仍会因 安装版本、许可和模块不同而变化;真实产品集成测试需要在对应 ANSYS 环境中运行。

Available Tools

41 tools
fluent_exitDisconnect FluentA
Destructive

Detach from Fluent or close an MCP-launched instance.

Inputs: shutdown_attached. Returns: ok, data, tool, error, +1 more

fluent_get_mapping_reportGet Fluent MappingA
Read-onlyIdempotent

Return structured MCP-to-TUI mapping history.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

fluent_get_residualsRead Fluent ResidualsA
Read-onlyIdempotent

Read the latest Fluent residual values.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

fluent_get_scriptGet Fluent JournalA
Read-onlyIdempotent

Return only the current session's generated Fluent journal.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

fluent_hook_udfHook Fluent UDFB

Attach a loaded UDF profile to a boundary field.

Inputs: zone_name (required), profile_name (required), phase_name, momentum_field. Returns: ok, data, tool, error, +1 more

fluent_initializeInitialize FluentC

Initialize the Fluent solution.

Inputs: method. Returns: ok, data, tool, error, +1 more

fluent_iterateRun Fluent IterationsC

Run Fluent solver iterations.

Inputs: timeout, iterations. Returns: ok, data, tool, error, +1 more

fluent_launchConnect FluentC

Launch Fluent or attach to a gRPC instance.

Inputs: ip, cwd, port, replace, +7 more. Returns: ok, data, tool, error, +1 more

fluent_list_udfsList Fluent UDFsB
Read-onlyIdempotent

List detected UDF profile hooks.

Inputs: zone_name. Returns: ok, data, tool, error, +1 more

fluent_load_udfLoad Fluent UDFA

Compile or interpret an existing Fluent UDF source file.

Inputs: source_file (required), compile. Returns: ok, data, tool, error, +1 more

fluent_read_caseRead Fluent CaseB

Read an existing Fluent case file.

Inputs: file_path (required). Returns: ok, data, tool, error, +1 more

fluent_read_meshRead Fluent MeshB

Read an existing Fluent mesh file.

Inputs: file_path (required). Returns: ok, data, tool, error, +1 more

fluent_reset_mapperReset Fluent MappingA
Idempotent

Clear the current Fluent session's mapping history.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

fluent_saveSave Fluent Case/DataA
Destructive

Write Fluent case and data using a path prefix.

Inputs: prefix (required), overwrite. Returns: ok, data, tool, error, +1 more

fluent_set_boundaryConfigure Fluent BoundaryC

Set one boundary type and validated properties.

Inputs: zone (required), bc_type (required), params. Returns: ok, data, tool, error, +1 more

fluent_set_materialAssign Fluent MaterialB

Assign a material to a Fluent cell zone.

Inputs: zone (required), material (required). Returns: ok, data, tool, error, +1 more

fluent_set_solverConfigure Fluent SolverA

Configure viscosity, energy, and steady/transient solver settings.

Inputs: energy, transient, viscous_model. Returns: ok, data, tool, error, +1 more

fluent_statusFluent StatusA
Read-onlyIdempotent

Return connection and version state without modifying Fluent.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

fluent_tuiExecute Fluent TUIB
Destructive

Execute arbitrary Fluent TUI after explicit unsafe confirmation.

Inputs: command (required), confirm_unsafe (required). Returns: ok, data, tool, error, +1 more

geometry_closeClose GeometryA
Destructive

Close the MCP-launched Geometry service.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

geometry_create_blockCreate Geometry BlockB

Create a centered block using SI length units.

Inputs: name, width, height, length, +3 more. Returns: ok, data, tool, error, +1 more

geometry_create_cylinderCreate Geometry CylinderB

Create a centered cylinder using SI length units.

Inputs: name, height, radius, center_x, +2 more. Returns: ok, data, tool, error, +1 more

geometry_create_designCreate Geometry DesignB

Create and select a new Geometry design.

Inputs: name. Returns: ok, data, tool, error, +1 more

geometry_create_sphereCreate Geometry SphereA

Create a centered sphere using SI length units.

Inputs: name, radius, center_x, center_y, +1 more. Returns: ok, data, tool, error, +1 more

geometry_exportExport GeometryA
Destructive

Export the active design to the exact requested STEP or IGES path.

Inputs: output_path (required), format, overwrite. Returns: ok, data, tool, error, +1 more

geometry_import_fileImport Geometry FileA

Insert an existing CAD file into the active design.

Inputs: file_path (required). Returns: ok, data, tool, error, +1 more

geometry_launchLaunch GeometryC

Launch a Geometry service for Discovery or SpaceClaim.

Inputs: mode, replace, timeout, version. Returns: ok, data, tool, error, +1 more

geometry_list_bodiesList Geometry BodiesA
Read-onlyIdempotent

List bodies in the active Geometry design.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

geometry_statusGeometry StatusA
Read-onlyIdempotent

Return Geometry connection and active-design state.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

mechanical_apply_loadApply Mechanical LoadB

Apply one typed load or support to one uniquely named selection.

Inputs: location (required), load_type (required), direction, magnitude, +2 more. Returns: ok, data, tool, error, +1 more

mechanical_exitDisconnect MechanicalA
Destructive

Detach from Mechanical or close an MCP-launched instance.

Inputs: shutdown_attached. Returns: ok, data, tool, error, +1 more

mechanical_get_mesh_settingsRead Mechanical Mesh SettingsA
Read-onlyIdempotent

Read configured global mesh settings and generated counts.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

mechanical_get_resultGet Mechanical ResultC

Read an existing result or optionally create and evaluate one.

Inputs: result_type (required), analysis_index, create_if_missing. Returns: ok, data, tool, error, +1 more

mechanical_importImport Mechanical GeometryA

Import an existing geometry file into the active Mechanical model.

Inputs: file_path (required). Returns: ok, data, tool, error, +1 more

mechanical_launchConnect MechanicalB

Launch Mechanical batch mode or attach to an existing gRPC instance and probe readiness.

Inputs: port, replace, connect_timeout. Returns: ok, data, tool, error, +1 more

mechanical_listList Mechanical ObjectsB
Read-onlyIdempotent

List bodies, named selections, or analyses.

Inputs: what. Returns: ok, data, tool, error, +1 more

mechanical_meshConfigure Mechanical MeshB

Configure mesh size and method, then optionally generate the mesh.

Inputs: method, timeout, generate, element_size, +1 more. Returns: ok, data, tool, error, +1 more

mechanical_scriptExecute Mechanical ScriptA
Destructive

Execute arbitrary Mechanical IronPython after explicit unsafe confirmation.

Inputs: script (required), confirm_unsafe (required), timeout. Returns: ok, data, tool, error, +1 more

mechanical_set_materialAssign Mechanical MaterialB

Assign a material to exactly one named body.

Inputs: body (required), material (required). Returns: ok, data, tool, error, +1 more

mechanical_solveSolve MechanicalB

Solve the active Mechanical model.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

mechanical_statusMechanical StatusA
Read-onlyIdempotent

Return transport, scripting, project, model, and analysis readiness.

Inputs: no named parameters. Returns: ok, data, tool, error, +1 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 41 tools

    Disambiguation4/5

    Domain prefixes (geometry_, mechanical_, fluent_) clearly separate tools, and within each domain actions like apply_load, solve, and get_result are distinct. The only potential overlap is between geometry_import_file and mechanical_import, but their descriptions clarify the active model.

    Naming Consistency4/5

    Tool names follow a domain_verb_noun snake_case pattern, which is predictable. However, retrieval verbs vary ('list', 'get', 'read') and lifecycle verbs differ ('close' for geometry, 'exit' for mechanical/fluent), creating minor inconsistency.

    Tool Count2/5

    With 41 tools, the server exceeds the 25+ threshold for 'too many' and may overwhelm agents. While the broad scope (Geometry, Mechanical, Fluent) justifies some size, the count is still heavy and would benefit from consolidation.

    Completeness4/5

    Core workflows are covered: geometry creation/import/export, mechanical setup/solve/result, and fluent setup/solve/save. Minor gaps exist, such as no geometry editing/deletion and limited result types, but these are workable for typical simulation tasks.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers