空间建模服务器

TopologicPy MCP服务器通过MCP协议将TopologicPy的空间建模能力暴露给LLM代理,支持自然语言指令创建、操作和导出3D建筑模型。

  • by Adventurous-Systems
  • Python
  • 本地部署
  • 22 星标
  • 更新于
在 GitHub 查看 Adventurous-Systems/topologicpy_MCP

使用说明

TopologicPy MCP服务器

A. 模型上下文协议 暴露的服务器 拓扑学 TopologicPy文档的空间建模功能,用于LLM代理,如Claude Code、Claude Desktop和其他MCP客户端。这是为了帮助我们围绕Topologic和TopologicPy开发更多工具而创建的

这能带来什么

请Claude(或任何配备MCP的LLM)通过自然语言构建架构模型:

“创建一栋3层办公楼,12m×20m,层高3.5m,然后向我展示邻接图并导出到IFC”

MCP服务器将这些请求转换为精确的TopologicPy操作,在整个对话中维护一个命名对象会话。

建筑

┌─────────────────────────────────────────────────┐
│              MCP Client (Claude Code, etc.)       │
│  Natural language ↔ tool calls                   │
└────────────────────┬────────────────────────────┘
                     │  MCP Protocol (stdio/SSE)
                     ▼
┌─────────────────────────────────────────────────┐
│            TopologicPy MCP Server                │
│  ┌───────────────────────────────────────────┐  │
│  │  Session Store (named topology objects)    │  │
│  │  • "building" → CellComplex               │  │
│  │  • "floor_0"  → Cell                      │  │
│  │  • "graph"    → Graph                     │  │
│  └───────────────────────────────────────────┘  │
│                                                  │
│  Tools: create, boolean, transform, query, I/O   │
│  Resources: session state, BREP strings          │
│  Prompts: building envelope, adjacency, grids    │
└────────────────────┬────────────────────────────┘
                     │
                     ▼
┌─────────────────────────────────────────────────┐
│                  TopologicPy                     │
│  Vertex → Edge → Wire → Face → Shell → Cell     │
│  CellComplex → Cluster → Graph → Dictionary     │
│  OpenCASCADE (BREP) • IfcOpenShell (IFC)        │
└─────────────────────────────────────────────────┘

可用工具(36个工具)

创造

工具 说明
create_vertex 在(x,y,z)处创建一个点
create_edge 两个顶点之间的线段
create_wire 有序顶点的折线
create_face_by_wire 从封闭的电线上看
create_face_rectangle 矩形面
create_face_circle 圆形面(多边形近似)
create_cell_by_faces 来自边界面的三维实体
create_cell_prism 盒子/矩形棱柱
create_cell_cylinder 圆柱形电池
create_cellcomplex_by_cells 合并单元组件(共享边界)
create_cluster 非结构化集合

布尔运算

工具 说明
boolean_union A➢B
boolean_difference A−B
boolean_intersect A∩B
self_merge 解决自身交叉问题

变换

工具 说明
translate 按矢量移动
rotate 绕轴旋转
scale 相对于原点的比例

查询与分析

工具 说明
list_topologies 列出会话中的所有命名对象
query_topology 详细信息(计数、质心、体积、面积)
get_vertices 提取顶点坐标
get_sub_topologies 提取并可选择存储子元素

图的运算

工具 说明
create_graph_from_topology 对偶/邻接图
graph_shortest_path 顶点之间的最短路径

词典(元数据)

工具 说明
set_dictionary 附加键值元数据
get_dictionary 读取附加元数据

进口/出口

工具 说明
export_brep 导出到BREP字符串/文件
import_brep 从BREP字符串/文件导入
export_obj 导出三角网格(OBJ)
export_ifc 导出到IFC(BIM)
import_ifc 从IFC文件导入

会话管理

工具 说明
remove_topology 从会话中删除
rename_topology 重命名对象
copy_topology 使用新名称进行深度复制

安装

紫外线(推荐)

cd topologic-mcp-server
uv venv
source .venv/bin/activate
uv pip install -e .

使用pip

cd topologic-mcp-server
pip install -e .

用法

使用克劳德代码

添加到您的Claude Code MCP配置中(~/.claude/claude_code_config.json):

{
  "mcpServers": {
    "topologic": {
      "command": "python",
      "args": ["-m", "topologic_mcp"],
      "cwd": "/path/to/topologic-mcp-server"
    }
  }
}

或者直接使用紫外线:

{
  "mcpServers": {
    "topologic": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/topologic-mcp-server", "topologic-mcp"]
    }
  }
}

使用克劳德桌面

增添 claude_desktop_config.json:

{
  "mcpServers": {
    "topologic": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/topologic-mcp-server", "topologic-mcp"]
    }
  }
}

独立(标准传输)

python -m topologic_mcp

配备MCP检查员(用于测试)

mcp dev src/topologic_mcp/server.py

对话示例

创建一个简单的建筑

User: Create a 3-storey building, 10m × 15m, 3m floor height

Claude: [calls create_vertex, create_cell_prism × 3, translate × 2,
         create_cellcomplex_by_cells, query_topology]

Result: CellComplex "building" with 3 cells, 16 faces, 33 edges, 20 vertices

分析空间邻接性

User: Show me which floors share faces in the building

Claude: [calls create_graph_from_topology with via_shared_faces=True,
         get_sub_topologies to list cells, query each cell]

Result: Graph with 3 vertices (one per floor) and 2 edges
        (floor_0↔floor_1, floor_1↔floor_2)

布尔运算

User: Cut a 2m diameter hole through the middle of floor_1

Claude: [calls create_cell_cylinder for the hole, translate to position,
         boolean_difference to subtract from floor_1]

Result: Updated floor_1 with cylindrical void

许可证

GPL-3.0或更高版本(与TopologicPy的许可证相匹配)

贡献

该服务器包装了TopologyPy的pure-Python API。要添加新工具,请执行以下操作:

  1. 添加一个 @mcp.tool() 装饰功能 server.py
  2. 遵循命名约定: verb_noun (例如。, create_vertex, export_brep)
  3. 始终接受 ctx: Context 作为第一个参数
  4. 使用 TopologyStore 从 ctx.request_context.lifespan_context
  5. 返回描述性字符串(LLM读取这些字符串)