Skip to main content
Glama
Followmyself

FEFLOW MCP Server

by Followmyself

FEFLOW MCP 服务器

通过 MCP(Model Context Protocol)协议,使 AI 助手能够操控 FEFLOW 7.5 地下水模拟软件。

架构

┌─────────────────────────────────────────────────────────┐
│  MCP 客户端 (Claude Code / VS Code)                      │
│  通过 stdio 通信                                         │
├─────────────────────────────────────────────────────────┤
│  server.py (Python 3.13, D:\anaconda\python.exe)        │
│  ├── MCP 协议处理 (mcp 库)                               │
│  ├── 工具定义 (19 个 MCP 工具)                           │
│  └── FEFLOWService (业务逻辑层)                          │
│       └── FEFLOWController (子进程管理)                   │
│            └── subprocess.Popen                          │
├─────────────────────────────────────────────────────────┤
│  feflow_bridge.py (Python 3.9, pytorch conda env)       │
│  ├── ifm 模块导入 (FEFLOW IFM Python API)                │
│  ├── stdin/stdout JSON 协议                              │
│  └── FEFLOWBridge 核心类                                 │
│       └── FEFLOW Kernel DLL (D:\专业软件\bin64\)         │
└─────────────────────────────────────────────────────────┘

Related MCP server: COMSOL MCP Server

为什么使用双 Python 版本?

  • FEFLOW 7.5 的 IFM Python API 仅支持 Python 3.6-3.9(通过 .pyd 文件)

  • MCP SDK (mcp 包) 需要 Python >= 3.10

  • 解决方案:MCP 服务器运行于 Python 3.13,通过子进程桥接到 Python 3.9 环境

文件结构

FEFLOW_MCP/
├── server.py               # MCP 服务器主入口 (Python 3.13)
├── feflow_controller.py    # 桥接控制器,管理子进程生命周期
├── feflow_bridge.py        # FEFLOW IFM 桥接脚本 (Python 3.9)
├── config.json             # 配置文件
├── requirements.txt        # Python 依赖
├── .mcp.json              # MCP 客户端配置
└── README.md               # 本文件

环境要求

组件

路径

说明

FEFLOW 7.5

D:\专业软件\

需设置 FEFLOW75_ROOT 环境变量

Python 3.13 (系统)

D:\anaconda\python.exe

运行 MCP 服务器,需安装 mcp

Python 3.9 (conda)

D:\anaconda\envs\pytorch\python.exe

运行 FEFLOW IFM API 桥接

安装

# 1. 进入项目目录
cd C:\Users\温涛\Desktop\FEFLOW_MCP

# 2. 安装 MCP 服务器依赖(Python 3.13 环境)
pip install mcp pydantic

# 3. 确认 Python 3.9 环境可用
D:\anaconda\envs\pytorch\python.exe --version  # 应输出 3.9.x

# 4. 配置 MCP 客户端
# 将 .mcp.json 中的内容合并到你的 MCP 客户端配置中

MCP 工具清单

文档管理

工具名

说明

必填参数

load_document

加载模型文件 (.fem/.dac)

path

save_document

保存模型

path (可选)

close_document

关闭模型

-

get_model_info

模型综合信息

-

网格操作

工具名

说明

必填参数

get_number_of_nodes

节点总数

-

get_number_of_elements

单元总数

-

get_node_coordinates

节点坐标

-

get_element_nodes

单元连接关系

-

get_mesh_stats

网格统计(含包围盒)

-

参数管理

工具名

说明

必填参数

list_parameters

列出可用参数类型

-

get_param_values

读取参数值

param_name

set_param_values

设置参数值

param_name, values

模拟结果

工具名

说明

必填参数

get_results

获取模拟结果

-

get_time_steps_info

时间步信息

-

材料属性 & 导出

工具名

说明

必填参数

get_material_properties

材料属性

-

export_results_csv

导出结果为 CSV

output_path

export_results_shapefile

导出网格为 GIS 格式

output_dir

系统

工具名

说明

必填参数

get_kernel_info

内核版本信息

-

使用示例

加载模型并查看信息:

1. load_document → path: "C:/models/aquifer.fem"
2. get_model_info → 获取节点/单元数量
3. get_mesh_stats → 获取包围盒范围
4. get_param_values → param_name: "P_CONDUCT"

支持的文件格式

  • .fem — FEFLOW 有限元模型文件

  • .dac — FEFLOW 模拟结果文件(含时间序列数据)

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with Aspen Plus process simulations through a standardized MCP interface, supporting simulation control, data access, and flowsheet manipulation.
    34
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    Enables AI agents to automate COMSOL Multiphysics simulations, including model management, geometry building, physics configuration, meshing, solving, and results visualization through the MCP protocol.
    78
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to automate COMSOL Multiphysics simulations, including model management, geometry building, physics configuration, meshing, solving, and results visualization via the MCP protocol.
    MIT