validate_ids
Validate IDS documents for required fields, specification applicability, IFC version compatibility, and XSD schema compliance to ensure buildingSMART standard adherence.
Instructions
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 } }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main asynchronous handler function for the 'validate_ids' tool. It performs comprehensive validation of the IDS document in the current session, including checks for title presence, specifications, applicability facets, valid IFC versions, and XSD schema compliance using IfcTester. Returns a detailed validation report with errors, warnings, and status.async def validate_ids(ctx: Context) -> Dict[str, Any]: """ Validate current session's IDS document. Validates: 1. Required fields present (title, specifications, etc.) 2. Each specification has applicability 3. IFC versions are valid 4. 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 } } """ try: ids_obj = await get_or_create_session(ctx) await ctx.info("Validating IDS document") errors = [] warnings = [] # Check has title has_title = bool(ids_obj.info.get("title")) if not has_title: errors.append("IDS must have a title") # Check has specifications has_specifications = len(ids_obj.specifications) > 0 if not has_specifications: errors.append("IDS must have at least one specification") # Valid IFC versions (from IDS 1.0 spec) valid_ifc_versions = {"IFC2X3", "IFC4", "IFC4X3", "IFC4X3_ADD2"} # Check each specification for i, spec in enumerate(ids_obj.specifications): spec_name = spec.name if spec.name else f"Specification {i}" # Check has name if not spec.name: warnings.append(f"Specification at index {i} has no name") # Check has applicability facets if not spec.applicability or len(spec.applicability) == 0: errors.append( f"Specification '{spec_name}' (index {i}) has no applicability facets. " "At least one applicability facet is required." ) # Check IFC versions are valid if hasattr(spec, 'ifcVersion'): ifc_versions = spec.ifcVersion if isinstance(spec.ifcVersion, list) else [spec.ifcVersion] for version in ifc_versions: if version not in valid_ifc_versions: warnings.append( f"Specification '{spec_name}' uses non-standard IFC version: {version}" ) # Validate XSD compliance by attempting to serialize and re-parse xsd_valid = True try: xml_string = ids_obj.to_string() # Try to parse it back with XSD validation validated_ids = ids.from_string(xml_string, validate=True) except Exception as e: xsd_valid = False errors.append(f"XSD validation failed: {str(e)}") valid = len(errors) == 0 await ctx.info(f"Validation complete: {'PASS' if valid else 'FAIL'}") return { "valid": valid, "errors": errors, "warnings": warnings, "specifications_count": len(ids_obj.specifications), "details": { "has_title": has_title, "has_specifications": has_specifications, "xsd_valid": xsd_valid } } except Exception as e: await ctx.error(f"Validation error: {str(e)}") raise ToolError(f"Validation error: {str(e)}")
- src/ids_mcp_server/server.py:40-42 (registration)Registration of the 'validate_ids' tool (and related 'validate_ifc_model') in the FastMCP server during initialization in the create_server function.# Register validation tools mcp_server.tool(validation.validate_ids) mcp_server.tool(validation.validate_ifc_model)
- The docstring of the validate_ids function defines the input (ctx parameter) and output schema/structure of the validation result, serving as the tool's schema documentation for MCP.""" Validate current session's IDS document. Validates: 1. Required fields present (title, specifications, etc.) 2. Each specification has applicability 3. IFC versions are valid 4. 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 } } """