IDS MCP服务器
AI驱动的buildingSMART IDS文件创建,100%合规
MCP(模型上下文协议)服务器,使AI代理能够确定地创建、验证和管理完全符合buildingSMART IDS 1.0标准的信息传递规范(IDS)文件。

  
特性
- ✅ 100%符合IDS 1.0标准 -所有导出都根据官方XSD模式进行验证
- ✅ IfcTester集成 -使用官方IfcOpenShell库
- ✅ FastMCP基于上下文的会话 -自动会话管理
- ✅ 测试驱动开发 -通过全面测试实现95%以上的代码覆盖率
- ✅ 确定性输出 -相同的输入总是产生相同的输出
- ✅ 类型安全 -带有Pydantic验证的完整类型提示
快速开始
安装
# Clone repository
git clone https://github.com/Quasar-Consulting-Group/ifc-ids-mcp.git
cd ifc-ids-mcp
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .使用Claude Desktop
添加到您的Claude Desktop配置(claude_desktop_config.json):
{
"mcpServers": {
"ids-mcp": {
"command": "python",
"args": ["-m", "ids_mcp_server"],
"env": {
"IDS_LOG_LEVEL": "INFO"
}
}
}
}程序化使用
from ifctester import ids
# The MCP server handles this automatically via tools
# But you can also use IfcTester directly:
# Create new IDS
my_ids = ids.Ids(title="Project Requirements")
# Add specification
spec = ids.Specification(name="Wall Requirements", ifcVersion=["IFC4"])
spec.applicability.append(ids.Entity(name="IFCWALL"))
requirement = ids.Property(
baseName="FireRating",
propertySet="Pset_WallCommon",
cardinality="required"
)
spec.requirements.append(requirement)
my_ids.specifications.append(spec)
# Export to XML
my_ids.to_xml("requirements.ids")可用的MCP工具
文档管理
- create_ids -创建新的IDS文档
- load_ids -从文件或XML字符串加载现有IDS
- export_ids -将IDS导出为XML并进行验证
- get_ids_info -获取文档结构和元数据
规格管理
- add_规范 -添加具有IFC版本和基数的规范
Facet管理
基本面
- add_entity_facet -添加IFC实体类型过滤器(例如IFCWALL)
- add_property_facet -添加属性要求
- add_attribute_face -添加IFC属性要求
高级面板
- add_classification_方面 -添加分类要求
- add_material_face -添加材料要求
- add_partof_facet -添加空间关系要求
限制管理
- add_enumeration_restriction -约束到有效值列表
- add_pattern_restriction -使用正则表达式模式进行约束
- add_bounds_restriction -限制数值范围
- add_length_restriction -约束字符串长度
验证
- validate_ids -根据XSD模式验证IDS文档
- validate_ifc_model -根据IDS验证IFC模型(额外功能)
早期验证和约束检查
MCP服务器包括 早期验证 在调用工具时立即捕获IDS 1.0模式违规,而不是等到导出时。这为AI代理提供了清晰、可操作的错误消息。
IDS 1.0模式约束
1.每种适用性的单一实体面
约束:IDS 1.0只允许每个规范的适用性部分有一个实体方面。
早期验证:The add_entity_facet 工具在添加面之前验证此约束:
# ✅ CORRECT: First entity facet
add_entity_facet(spec_id="S1", location="applicability", entity_name="IFCWALL")
# ❌ INCORRECT: Second entity facet raises ToolError immediately
add_entity_facet(spec_id="S1", location="applicability", entity_name="IFCDOOR")
# Error: "IDS 1.0 XSD constraint violation: Only ONE entity facet is allowed..."变通方案:为每种实体类型创建单独的规范:
# Specification 1: Walls
add_specification(name="Wall Requirements", ifc_versions=["IFC4"], identifier="S1")
add_entity_facet(spec_id="S1", location="applicability", entity_name="IFCWALL")
# Specification 2: Doors
add_specification(name="Door Requirements", ifc_versions=["IFC4"], identifier="S2")
add_entity_facet(spec_id="S2", location="applicability", entity_name="IFCDOOR")2.属性面所需的属性集
约束:IfcTester需要 property_set 有效IDS导出的参数。
早期验证:The add_property_facet 工具在添加方面之前验证此要求:
# ❌ INCORRECT: Missing property_set raises ToolError immediately
add_property_facet(
spec_id="S1",
location="requirements",
property_name="FireRating"
)
# Error: "Property facet validation error: 'property_set' parameter is required..."
# ✅ CORRECT: Include property_set parameter
add_property_facet(
spec_id="S1",
location="requirements",
property_name="FireRating",
property_set="Pset_WallCommon"
)通用属性集:
Pset_WallCommon-墙体特性Pset_DoorCommon-门属性Pset_WindowCommon-窗口属性Pset_SpaceCommon-空间属性Pset_Common-自定义/通用属性
早期验证的好处
- 即时反馈 -在工具调用时而非导出时捕获的错误
- 清除错误消息 -包括变通方法和示例
- 防止无效状态 -IDS文档在整个创建过程中保持有效
- 更好的AI代理体验 -代理人收到可操作的指导
看 CLAUDE.md 有关IDS 1.0约束的详细文档。
建筑
┌─────────────────────────────────────────────┐
│ AI Agent (Claude, GPT) │
└────────────────────┬────────────────────────┘
│ MCP Protocol
┌────────────────────▼────────────────────────┐
│ FastMCP Server │
│ ┌──────────────────────────────────────┐ │
│ │ MCP Tools (15+ tools) │ │
│ └───────────────┬──────────────────────┘ │
│ ┌───────────────▼──────────────────────┐ │
│ │ Session Manager (Context) │ │
│ └───────────────┬──────────────────────┘ │
│ ┌───────────────▼──────────────────────┐ │
│ │ IfcTester Integration (IDS Engine) │ │
│ └──────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
│
▼
IDS XML File (100% XSD compliant)发展
测试驱动开发
本项目严格遵循TDD方法:
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src/ids_mcp_server --cov-report=html
# Run specific test category
pytest tests/unit/ -v # Unit tests
pytest tests/integration/ -v # Integration tests
pytest tests/validation/ -v # XSD validation tests
# Must maintain 95%+ coverage
pytest tests/ --cov-fail-under=95TDD工作流程(红绿重构)
- 红 -写入失败测试
- 绿色 -实现要通过的最小代码
- 重构 -提高代码质量
例子:
# RED: Write failing test
def test_create_specification():
result = add_specification(name="Test", ifc_versions=["IFC4"])
assert result["status"] == "success"
# GREEN: Implement
def add_specification(name, ifc_versions):
return {"status": "success"}
# REFACTOR: Improve (keep tests passing)代码质量
# Format code
black src/ tests/
# Lint code
ruff check src/ tests/
# Type checking (optional)
mypy src/项目结构
ifc-ids-mcp/
├── src/
│ └── ids_mcp_server/
│ ├── __init__.py
│ ├── __main__.py
│ ├── server.py # FastMCP server
│ ├── config.py # Configuration
│ ├── version.py # Version management
│ ├── session/ # Session management
│ │ ├── manager.py
│ │ ├── storage.py
│ │ ├── cleanup.py
│ │ └── models.py # Session data models
│ └── tools/ # MCP tools (17 total)
│ ├── document.py
│ ├── specification.py
│ ├── facets.py
│ ├── restrictions.py # Phase 007
│ ├── validation.py # Phase 008
│ └── validators.py # Early validation helpers
├── tests/ # 168 tests, 94% coverage
│ ├── unit/ # Unit tests
│ ├── component/ # Component tests
│ ├── integration/ # Integration tests
│ └── validation/ # XSD compliance tests
│ └── fixtures/ # Test fixtures
├── samples/ # Sample IDS/IFC files
│ ├── wall_fire_rating.ids
│ └── walls-fire-rating.ifc
├── specs/ # Implementation plans (PRDs)
├── .mcp.json # MCP server configuration
├── .coveragerc # Coverage configuration
├── constitution.md # Project principles
├── DESIGN_SPECIFICATION.md # Technical specification
├── CLAUDE.md # AI agent guide
├── pyproject.toml
├── pytest.ini
└── README.md宪法原则
该项目遵循6个不可协商的原则:
- 100%IDS架构合规性 -所有导出都根据XSD进行验证
- 测试驱动开发 -95%以上的覆盖率,代码前测试
- IfcTester集成优先 -无自定义XML生成
- 确定性生成 -相同的输入=相同的输出
- FastMCP基于上下文的会话 -自动会话管理
- Python最佳实践 -类型提示、PEP 8、现代Python
看 宪法 了解全部细节。
文档
依赖项
核心
- fastmcp -MCP服务器框架
- ifctester -IDS编写和验证(来自IfcOpenShell)
- 派迪克 -数据验证
发展
- pytest -测试框架
- pytest异步 -异步测试支持
- 新冠肺炎 -覆盖率报告
- 黑色 -代码格式
- 颈毛 -Linting
参考文献
- IDS标准: https://www.buildingsmart.org/standards/bsi-standards/information-delivery-specification-ids/
- IDS XSD架构: https://standards.buildingsmart.org/IDS/1.0/ids.xsd
- IfcTester文档: https://docs.ifcopenshell.org/ifctester.html
- FastMCP: https://gofastmcp.com/
- buildingSMART: https://www.buildingsmart.org/
许可证
MIT许可证-请参阅 许可证 详细信息文件
贡献
- 阅读 宪法 项目原则
- 遵循TDD方法(红绿重构)
- 确保95%以上的测试覆盖率
- 所有导出必须根据IDS 1.0 XSD进行验证
- 对所有IDS操作使用IfcTester
支持
- 问题: https://github.com/Quasar-Consulting-Group/ifc-ids-mcp/issues
- 讨论: https://github.com/Quasar-Consulting-Group/ifc-ids-mcp/discussions
______________________________________________________________________
状态: ✅ 实施完成|94%的测试覆盖率|17个MCP工具|168个测试|早期验证
建于❤️ 使用 IfcOpenShell 和 FastMCP
