IDS MCP Server
IDS MCP 服务器
AI 驱动的 100% 合规 buildingSMART IDS 文件创建
一个 MCP(模型上下文协议)服务器,使 AI 智能体能够确定性地创建、验证和管理完全符合 buildingSMART IDS 1.0 标准的信息交付规范 (IDS) 文件。
特性
✅ 100% 符合 IDS 1.0 标准 - 所有导出文件均通过官方 XSD 模式验证
✅ IfcTester 集成 - 使用官方 IfcOpenShell 库
✅ 基于 FastMCP 上下文的会话 - 自动会话管理
✅ 测试驱动开发 - 95% 以上的代码覆盖率及全面的测试
✅ 确定性输出 - 相同的输入始终产生相同的输出
✅ 类型安全 - 完整的类型提示及 Pydantic 验证
Related MCP server: ifc-mcp
快速入门
安装
# 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_specification - 添加带有 IFC 版本和基数的规范
方面 (Facet) 管理
基础方面
add_entity_facet - 添加 IFC 实体类型过滤器(例如 IFCWALL)
add_property_facet - 添加属性要求
add_attribute_facet - 添加 IFC 属性要求
高级方面
add_classification_facet - 添加分类要求
add_material_facet - 添加材料要求
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 允许每个规范的适用性部分仅包含一个实体方面。
早期验证: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 导出。
早期验证: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 智能体体验 - 智能体获得可操作的指导
有关 IDS 1.0 约束的详细文档,请参阅 CLAUDE.md。
架构
┌─────────────────────────────────────────────┐
│ 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) - 编写失败的测试
绿 (GREEN) - 实现通过测试的最少代码
重构 (REFACTOR) - 提高代码质量
示例:
# 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
详情请参阅 constitution.md。
文档
依赖项
核心
fastmcp - MCP 服务器框架
ifctester - IDS 创作与验证(来自 IfcOpenShell)
pydantic - 数据验证
开发
pytest - 测试框架
pytest-asyncio - 异步测试支持
pytest-cov - 覆盖率报告
black - 代码格式化
ruff - 代码检查
参考资料
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 许可证 - 详情请参阅 LICENSE 文件
贡献
阅读 constitution.md 了解项目原则
遵循 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
Available Tools
17 toolsadd_attribute_facetC
Add an attribute facet to a specification.
Args: spec_id: Specification identifier location: "applicability" or "requirements" attribute_name: Attribute name (e.g., "Name", "Description") ctx: FastMCP Context (auto-injected) value: Required value or pattern cardinality: "required", "optional", or "prohibited"
Returns: {"status": "added", "facet_type": "attribute", "spec_id": "S1"}
Inputs: spec_id (required), location (required), attribute_name (required), value, +1 more. Returns: object
add_bounds_restrictionB
Add numeric bounds restriction.
Args: spec_id: Specification identifier or name facet_index: Index of facet in location (0-based) parameter_name: Which parameter to restrict (e.g., "value") base_type: XSD base type (e.g., "xs:double", "xs:integer") ctx: FastMCP Context (auto-injected) location: "applicability" or "requirements" (default: "requirements") min_inclusive: Minimum value (inclusive) max_inclusive: Maximum value (inclusive) min_exclusive: Minimum value (exclusive) max_exclusive: Maximum value (exclusive)
Returns: {"status": "added", "restriction_type": "bounds", "spec_id": "S1"}
Example: Add bounds to property value: Height must be between 2.4 and 3.0 meters
Inputs: spec_id (required), facet_index (required), parameter_name (required), base_type (required), +5 more. Returns: object
add_classification_facetA
Add a classification facet to a specification.
Args: spec_id: Specification identifier location: "applicability" or "requirements" classification_value: Classification code or pattern ctx: FastMCP Context (auto-injected) classification_system: Classification system name or URI cardinality: "required", "optional", or "prohibited"
Returns: {"status": "added", "facet_type": "classification", "spec_id": "S1"}
Inputs: spec_id (required), location (required), classification_value (required), classification_system, +1 more. Returns: object
add_entity_facetA
Add an entity facet to a specification.
IMPORTANT: IDS 1.0 allows only ONE entity facet per applicability section. If you need multiple entity types, create separate specifications.
Args: spec_id: Specification identifier location: "applicability" or "requirements" entity_name: IFC entity name (e.g., "IFCWALL") ctx: FastMCP Context (auto-injected) predefined_type: Optional predefined type cardinality: "required", "optional", or "prohibited" (requirements only)
Returns: {"status": "added", "facet_type": "entity", "spec_id": "S1"}
Raises: ToolError: If trying to add second entity to applicability section
Inputs: spec_id (required), location (required), entity_name (required), predefined_type, +1 more. Returns: object
add_enumeration_restrictionA
Add enumeration restriction (list of allowed values).
Args: spec_id: Specification identifier or name facet_index: Index of facet in location (0-based) parameter_name: Which parameter to restrict (e.g., "value", "propertySet") base_type: XSD base type (e.g., "xs:string", "xs:integer") values: List of allowed values ctx: FastMCP Context (auto-injected) location: "applicability" or "requirements" (default: "requirements")
Returns: {"status": "added", "restriction_type": "enumeration", "spec_id": "S1"}
Example: Add enumeration to property value: FireRating must be "REI30", "REI60", or "REI90"
Inputs: spec_id (required), facet_index (required), parameter_name (required), base_type (required), +2 more. Returns: object
add_length_restrictionB
Add string length restriction.
Args: spec_id: Specification identifier or name facet_index: Index of facet in location (0-based) parameter_name: Which parameter to restrict (e.g., "value") base_type: XSD base type (e.g., "xs:string") ctx: FastMCP Context (auto-injected) location: "applicability" or "requirements" (default: "requirements") length: Exact length min_length: Minimum length max_length: Maximum length
Returns: {"status": "added", "restriction_type": "length", "spec_id": "S1"}
Example: Add length restriction to attribute value: Tag must be between 5 and 50 characters
Inputs: spec_id (required), facet_index (required), parameter_name (required), base_type (required), +4 more. Returns: object
add_material_facetB
Add a material facet to a specification.
Args: spec_id: Specification identifier location: "applicability" or "requirements" material_value: Material name, category, or URI ctx: FastMCP Context (auto-injected) cardinality: "required", "optional", or "prohibited"
Returns: {"status": "added", "facet_type": "material", "spec_id": "S1"}
Inputs: spec_id (required), location (required), material_value (required), cardinality. Returns: object
add_partof_facetC
Add a partOf facet to a specification.
Args: spec_id: Specification identifier location: "applicability" or "requirements" relation: Relationship type (e.g., "IFCRELCONTAINEDINSPATIALSTRUCTURE") parent_entity: Parent entity name (e.g., "IFCSPACE") ctx: FastMCP Context (auto-injected) parent_predefined_type: Optional predefined type for parent cardinality: "required", "optional", or "prohibited"
Returns: {"status": "added", "facet_type": "partof", "spec_id": "S1"}
Inputs: spec_id (required), location (required), relation (required), parent_entity (required), +2 more. Returns: object
add_pattern_restrictionA
Add pattern restriction (regex matching).
Args: spec_id: Specification identifier or name facet_index: Index of facet in location (0-based) parameter_name: Which parameter to restrict (e.g., "value") base_type: XSD base type (e.g., "xs:string") pattern: Regular expression pattern ctx: FastMCP Context (auto-injected) location: "applicability" or "requirements" (default: "requirements")
Returns: {"status": "added", "restriction_type": "pattern", "spec_id": "S1"}
Example: Add pattern to attribute value: Name must match "EW-[0-9]{3}"
Inputs: spec_id (required), facet_index (required), parameter_name (required), base_type (required), +2 more. Returns: object
add_property_facetA
Add a property facet to a specification.
IMPORTANT: The property_set parameter is REQUIRED for valid IDS export.
Args: spec_id: Specification identifier location: "applicability" or "requirements" property_name: Property name (e.g., "FireRating") ctx: FastMCP Context (auto-injected) property_set: Property set name (e.g., "Pset_WallCommon") - REQUIRED data_type: IFC data type (e.g., "IFCLABEL") value: Required value or pattern cardinality: "required", "optional", or "prohibited"
Returns: {"status": "added", "facet_type": "property", "spec_id": "S1"}
Raises: ToolError: If property_set is None or empty
Inputs: spec_id (required), location (required), property_name (required), property_set, +3 more. Returns: object
add_specificationB
Add a specification to the current session's IDS document.
Args: name: Specification name ifc_versions: List of IFC versions (e.g., ["IFC4", "IFC4X3"]) ctx: FastMCP Context (auto-injected) identifier: Optional unique identifier description: Why this information is required instructions: How to fulfill requirements min_occurs: Minimum occurrences (0 = optional) max_occurs: Maximum occurrences (int or "unbounded")
Returns: { "status": "added", "spec_id": "S1", "ifc_versions": ["IFC4"] }
Inputs: name (required), ifc_versions (required), identifier, description, +3 more. Returns: object
create_idsA
Create a new IDS document for this session.
Session is automatically tracked by FastMCP - no session_id parameter needed!
Args: title: Document title (required) ctx: FastMCP Context (auto-injected) author: Author email or name version: Version string date: Date in YYYY-MM-DD format description: Document description copyright: Copyright notice milestone: Project milestone purpose: Purpose of this IDS
Returns: { "status": "created", "session_id": "auto-generated-by-fastmcp", "title": "..." }
Inputs: title (required), author, version, date, +4 more. Returns: object
export_idsA
Export IDS document to XML file using IfcTester.
Uses current session automatically - no session_id parameter needed!
Args: ctx: FastMCP Context (auto-injected) output_path: File path (optional, returns XML string if not provided) validate: Whether to validate against XSD (default: True)
Returns: { "status": "exported", "xml": "...", # If no output_path "file_path": "...", # If output_path provided "validation": {"valid": true, "errors": []} }
Inputs: output_path, validate. Returns: object
get_ids_infoA
Get current session's IDS document structure.
Uses current session automatically - no session_id parameter needed!
Args: ctx: FastMCP Context (auto-injected)
Returns: { "title": "...", "author": "...", "specification_count": 3, "specifications": [...] }
Inputs: no named parameters. Returns: object
load_idsA
Load an existing IDS file into the current session.
Replaces any existing IDS in this session.
Args: source: File path or XML string ctx: FastMCP Context (auto-injected) source_type: "file" or "string"
Returns: { "status": "loaded", "title": "...", "specification_count": 3, "specifications": [...] }
Inputs: source (required), source_type. Returns: object
validate_idsA
Validate current session's IDS document.
Validates:
Required fields present (title, specifications, etc.)
Each specification has applicability
IFC versions are valid
XSD schema compliance (via IfcTester)
Args: ctx: FastMCP Context (auto-injected)
Returns: { "valid": true, "errors": [], "warnings": [], "specifications_count": 3, "details": { "has_title": true, "has_specifications": true, "xsd_valid": true } }
Inputs: no named parameters. Returns: object
validate_ifc_modelA
Validate an IFC model against the current session's IDS specifications.
This bonus feature leverages IfcTester's IFC validation capabilities.
Args: ifc_file_path: Path to IFC file ctx: FastMCP Context (auto-injected) report_format: "console", "json", or "html"
Returns (json format): { "status": "validation_complete", "total_specifications": 3, "passed_specifications": 2, "failed_specifications": 1, "report": { "specifications": [ { "name": "Wall Fire Rating", "status": "passed", "applicable_entities": 25, "passed_entities": 25, "failed_entities": 0 }, ... ] } }
Inputs: ifc_file_path (required), report_format. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Each tool has a clearly distinct purpose with no overlap. The 'add_' tools create specific facet or restriction types (e.g., attribute, bounds, classification), while the management tools (create_ids, export_ids, etc.) handle document lifecycle operations. The descriptions clearly differentiate what each tool does, preventing agent confusion.
All tools follow a consistent verb_noun pattern with snake_case throughout. The 'add_' prefix is used uniformly for facet/restriction creation tools, while management tools use clear verbs like create, export, get, load, and validate. This predictable naming makes the tool set easy to navigate and understand.
With 17 tools, this server provides comprehensive coverage for IDS document creation and validation. The count is well-scoped for the domain, including core operations (create, export, validate), facet types (entity, property, material, etc.), and restriction types (bounds, enumeration, pattern). Each tool earns its place without redundancy.
The tool set provides complete coverage for IDS document lifecycle management. It includes document creation (create_ids), loading (load_ids), editing (add_* facets/restrictions), inspection (get_ids_info), validation (validate_ids), export (export_ids), and even model validation (validate_ifc_model). All essential CRUD operations are present with no apparent gaps.
Maintenance
Related MCP Connectors
Build, check, and export parametric CAD models in your ForgeCAD Projects from your AI agent.
15 deterministic validation tools for AI agents: tax IDs (15 countries), VAT, IBAN, LEI, HS codes.
Agent verification tools: CSV quality, citation checks, AI-readiness audits, requirement extraction
Edit IFC/BIM building models by language: quantities, checks, edits, new elements, undoable.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables AI assistants to create, edit, and export IFC5/IFCX building information models through natural language, handling spatial structure, elements, geometry, metadata, validation, and export.7326MIT
- AlicenseAqualityDmaintenanceEnables AI agents to load, query, and analyze IFC building model files, including spatial structures, elements, properties, materials, and geometry.201MIT
- FlicenseAqualityDmaintenanceEnables AI assistants to query standardized building classifications, properties, and data dictionaries from buildingSMART for BIM model enrichment.93-
- AlicenseAqualityCmaintenanceEnables AI assistants to inspect, create, and report on IFC/BIM files locally, and to open models in a viewer with BCF viewpoint support.5228 npm14Apache 2.0