构建MOTIF MCP服务器
概述
此MCP服务器将BuildingMOTIF功能集成到您的AI编码环境中,使您能够:
- 发现可用模板 来自Brick、自定义本体和基于SHACL的库
- 了解点要求 用于指导数据收集的每个模板
- 迭代构建Brick模型 通过使用建筑数据评估模板
- 应用自定义验证规则 使用SHACL形状执行组织标准
- 与文档分析集成 从PDF、CSV、电子表格和其他来源提取设备和点信息
无论您是处理遗留的建筑数据、创建新的Brick模型还是改进现有的模型,此服务器都可以帮助您系统地将非结构化数据转换为语义建筑模型。
安装
此包尚未发布到PyPI。使用以下命令直接从GitHub安装 uv:
uv pip install git+https://github.com/epaulson/buildingmotif-mcp.git或者克隆并在本地安装:
git clone https://github.com/epaulson/buildingmotif-mcp.git
cd buildingmotif-mcp
uv pip install -e .快速开始
1.VS Code或Claude的基本用法
在工具的设置中配置MCP服务器,以包含BuildingMOTIF服务器。服务器提供以下工具:
- 列出可用模板 -查看可用于模型构建的模板
- 浏览模板详细信息 -了解特定模板的参数和要求
- 评估模板 -通过提供参数绑定从模板生成RDF图
- 验证模型 -根据Brick和自定义SHACL形状检查模型
- 查询本体 -在加载的本体中搜索类、属性和模式
2.配置
服务器从捆绑包中加载本体和模板 ontologies/ 默认目录,其中包括:
- 砖块 -具有标准构建模板的Brick本体
- 阿什雷223 -新兴的ASHRAE 223语义建筑建模标准。Brick和223一起工作。
- 其他领域特定的本体
使用自定义本体论
要在配置中添加自定义本体或SHACL规则,请创建或修改MCP配置:
{
"mcpServers": {
"buildingmotif": {
"command": "uv",
"args": ["run", "buildingmotif-mcp"],
"env": {
"BUILDINGMOTIF_ONTOLOGY_PATHS": "/path/to/custom/ontologies:/path/to/local/org/ontologies"
}
}
}
}示例:使用当地组织标准
许多组织对其Brick模型有特定的要求。此示例显示了如何定义和使用组织标准。
创建本地组织本体
创建文件 my-org/shapes.ttl 它定义了您的组织要求:
@prefix sh: .
@prefix brick: .
@prefix rdf: .
@prefix rdfs: .
@prefix myorg: .
# Shape: Every floor must have at least one temperature sensor
myorg:FloorTemperatureSensorShape
a sh:NodeShape ;
sh:targetClass brick:Floor ;
sh:property [
sh:path brick:hasPoint ;
sh:qualifiedValueShape [
sh:class brick:Temperature_Sensor ;
] ;
sh:qualifiedMinCount 1 ;
sh:message "Every floor must have at least one temperature sensor" ;
] .
# Shape: Equipment labels must follow naming convention
myorg:EquipmentNameShape
a sh:NodeShape ;
sh:targetClass brick:Equipment ;
sh:property [
sh:path rdfs:label ;
sh:pattern "^[A-Z]{2,4}[0-9]{1,3}(-[A-Z0-9]+)?$" ;
sh:message "Equipment labels must follow pattern: XX-000 or XXXX-000" ;
] .配置服务器以使用您的形状
更新您的MCP配置,以包括您的本地组织本体:
{
"mcpServers": {
"buildingmotif": {
"command": "uv",
"args": ["run", "buildingmotif-mcp"],
"env": {
"BUILDINGMOTIF_ONTOLOGY_PATHS": "./my-org"
}
}
}
}在工作流中使用
配置服务器后,您可以:
- 请Claude/AI分析您的建筑数据:
I have a CSV with equipment names and a PDF with floor layouts.
Using the MCP server, help me understand what templates are available
and what building structure I need to create.- 探索模板和要求:
服务器列出来自Brick的模板(例如。, Air_Handler_Unit, Zone_Air_Temperature_Sensor) 以及您的自定义形状(例如地板温度要求)。
- 指导模型构建:
For each floor in my building, I need to create a Brick model.
What does the AHU template need? What other points should I define?
Use the MCP server to help me structure this correctly and validate
against our org standards.- 逐步验证:
在构建模型时,服务器会根据Brick标准进行验证 以及您的组织SHACL形状,及早发现问题。
项目结构
buildingmotif-mcp/
├── README.md
├── pyproject.toml
├── buildingmotif_mcp/
│ ├── __init__.py
│ ├── main.py # MCP server entry point
│ ├── server.py # Core server implementation
│ ├── tools.py # MCP tools/handlers
│ └── ontology.py # Ontology management
├── ontologies/
│ ├── brick/ # Brick ontology
│ ├── ashrae-223/ # ashrae 223 ontology
│ └── ...
└── examples/
└── sample-org/
└── shapes.ttl # Example organizational shapesMCP工具
服务器当前向您的AI助手公开以下工具:
库和模板发现
list_libraries()-列出带有元数据(描述、类型、标签)的可用库list_templates(library_name?)-列出库中的模板,或省略library_name返回库中的所有模板get_template_details(library_name, template_name)-获取模板的参数和结构
计划中(即将推出)
search_templates(keyword)-查找与查询匹配的模板evaluate_template(template_name, parameters)-从模板绑定生成RDF图get_template_parameters(template_name)-获取必需和可选参数list_ontologies()-查看加载的本体及其源代码get_shape_requirements(shape_name)-了解SHACL形状需要什么find_class_by_keyword(keyword)-搜索本体类
模型验证
validate_model(rdf_content)-根据加载的本体和SHACL形状检查模型get_validation_report(model_uri)-获取详细的验证结果
工作流助手
suggest_equipment_templates(equipment_type)-获取设备的推荐模板get_point_requirements(template_name)-列出模板通常需要的所有点
典型工作流程
以下是您在人工智能辅助建筑建模工作流程中如何使用此服务器:
# 1. AI reads your building data (PDF, CSV, spreadsheet)
# 2. AI asks the MCP server: "What templates are available for an AHU?"
# → Server returns AHU template with parameters: {name}
# 3. AI extracts AHU information from your data
# 4. AI asks the MCP server: "What points does an AHU template need?"
# → Server lists: Supply Fan, Cooling Coil, Dampers, Points, etc.
# 5. AI maps your data to template requirements
# 6. AI uses the server to evaluate templates:
# → evaluate_template("AHU", {"name": "bldg:Core_ZN_AHU_1"})
# → Returns RDF graph with AHU structure
# 7. AI builds up model incrementally
# 8. AI validates: "Does my model match our org standards?"
# → Server checks against custom SHACL shapes
# → Returns any validation errors or warnings
# 9. Iterate: Refine data extraction, add more equipment/points
# 10. Export: Get final Brick RDF model for downstream use发展
这是一个积极的发展项目。未来的增强功能可能包括:
- 入口连接器 用于常见数据源(BACnet、Haystack等)
- 增量模型构建 -支持部分模板评估
- 形状生成 -从图案自动生成SHACL形状
- 模型比较 -识别模型版本之间的差异
- 出口公用事业 -输出到Haystack、JSON-LD等。
贡献
欢迎投稿!该项目的组织使添加新工具和功能变得容易。
许可证
有关详细信息,请参阅LICENSE文件。
资源
库元数据文件
您可以通过创建一个同名的JSON文件来为任何本体文件添加元数据 .metadata.
例子:
ontologies/brick/Brick-subset.ttl
ontologies/brick/Brick-subset.ttl.metadata格式:
{
"name": "Brick Schema",
"description": "Brick is a uniform metadata schema for buildings...",
"type": "builtin",
"version": "1.3",
"url": "https://brickschema.org/",
"tags": ["hvac", "buildings", "iot", "metadata"]
}笔记:
type应builtin对于捆绑库和custom针对特定站点的库。- 任何其他字段都将保留并返回
list_libraries.
