Skip to main content
Glama

validate_ifc_model

Validate IFC models against IDS specifications to ensure compliance with buildingSMART standards. Checks architectural and engineering data for accuracy and completeness.

Instructions

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 }, ... ] } }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ifc_file_pathYes
report_formatNojson

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'validate_ifc_model' tool. Loads an IFC file using ifcopenshell, validates it against the current IDS session's specifications using ifctester.ids, and generates a report in the specified format (console, json, or html). Handles errors and provides structured output with pass/fail counts per specification.
    async def validate_ifc_model(
        ifc_file_path: str,
        ctx: Context,
        report_format: str = "json"
    ) -> Dict[str, Any]:
        """
        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
                        },
                        ...
                    ]
                }
            }
        """
        import json as json_lib
    
        try:
            ids_obj = await get_or_create_session(ctx)
    
            await ctx.info(f"Validating IFC model: {ifc_file_path}")
    
            # Validate file exists
            if not Path(ifc_file_path).exists():
                raise ToolError(f"IFC file not found: {ifc_file_path}")
    
            # Check has specifications
            if not ids_obj.specifications:
                raise ToolError("IDS has no specifications to validate against")
    
            # Load IFC file
            await ctx.info("Loading IFC file...")
            ifc_file = ifcopenshell.open(ifc_file_path)
    
            # Validate
            await ctx.info("Running validation...")
            ids_obj.validate(ifc_file)
    
            # Generate report
            if report_format == "console":
                reporter.Console(ids_obj).report()
                return {"status": "validation_complete", "format": "console"}
    
            elif report_format == "json":
                json_reporter = reporter.Json(ids_obj)
                json_reporter.report()
                raw_report = json_reporter.to_string()
    
                # Parse the JSON report to extract structured data
                try:
                    report_data = json_lib.loads(raw_report)
    
                    # Extract specification-level summary
                    specifications_summary = []
                    passed_count = 0
                    failed_count = 0
    
                    for spec in ids_obj.specifications:
                        # Count applicable, passed, and failed entities for this spec
                        applicable = 0
                        passed = 0
                        failed = 0
    
                        # IfcTester stores results in spec after validation
                        if hasattr(spec, 'requirements'):
                            for req in spec.requirements:
                                if hasattr(req, 'failed_entities'):
                                    failed += len(req.failed_entities) if req.failed_entities else 0
                                if hasattr(req, 'passed_entities'):
                                    passed += len(req.passed_entities) if req.passed_entities else 0
    
                        applicable = passed + failed
                        spec_status = "passed" if failed == 0 and applicable > 0 else "failed" if failed > 0 else "no_applicable_entities"
    
                        if spec_status == "passed":
                            passed_count += 1
                        elif spec_status == "failed":
                            failed_count += 1
    
                        specifications_summary.append({
                            "name": spec.name if spec.name else f"Specification {len(specifications_summary)}",
                            "status": spec_status,
                            "applicable_entities": applicable,
                            "passed_entities": passed,
                            "failed_entities": failed
                        })
    
                    return {
                        "status": "validation_complete",
                        "total_specifications": len(ids_obj.specifications),
                        "passed_specifications": passed_count,
                        "failed_specifications": failed_count,
                        "report": {
                            "specifications": specifications_summary,
                            "raw_json": report_data  # Include original report
                        }
                    }
                except Exception as parse_error:
                    # Fallback if parsing fails - return raw report
                    await ctx.warning(f"Could not parse report structure: {parse_error}")
                    return {
                        "status": "validation_complete",
                        "total_specifications": len(ids_obj.specifications),
                        "format": "json",
                        "report": raw_report
                    }
    
            elif report_format == "html":
                html_reporter = reporter.Html(ids_obj)
                html_reporter.report()
                return {
                    "status": "validation_complete",
                    "total_specifications": len(ids_obj.specifications),
                    "format": "html",
                    "html": html_reporter.to_string()
                }
    
            else:
                raise ToolError(f"Invalid report format: {report_format}. Must be 'console', 'json', or 'html'")
    
        except FileNotFoundError as e:
            await ctx.error(f"File not found: {str(e)}")
            raise ToolError(f"File not found: {str(e)}")
        except Exception as e:
            await ctx.error(f"IFC validation error: {str(e)}")
            raise ToolError(f"IFC validation error: {str(e)}")
  • Registers the validate_ifc_model tool with the FastMCP server instance in the create_server function.
    mcp_server.tool(validation.validate_ifc_model)
  • Imports the validation module (containing validate_ifc_model) for tool registration.
    from ids_mcp_server.tools import document, specification, facets, validation, restrictions
  • Type hints and docstring defining the tool's input parameters (ifc_file_path: str, ctx: Context, report_format: str = "json") and output format (Dict[str, Any] with status, counts, and report). Serves as the schema for the tool.
    """
    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
                    },
                    ...
                ]
            }
        }
    """
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that this is a validation tool (implying read-only behavior) and mentions it's a 'bonus feature,' which adds some context. However, it lacks details on permissions, rate limits, error handling, or whether it modifies the IFC file, leaving behavioral traits partially covered but incomplete.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The additional details on args and returns are structured but slightly verbose; however, every sentence adds value (e.g., explaining IfcTester and return format), with minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of validation with 2 parameters and no annotations, the description is complete enough. It includes purpose, parameter semantics, and a detailed return format in the output schema, which eliminates the need to explain return values. This covers essential context for the agent to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining 'ifc_file_path' as the path to the IFC file and 'report_format' with specific enum values ('console', 'json', 'html'), including a default of 'json' in the schema. This provides clear semantics beyond the bare schema, though it could elaborate on path format or context usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('validate') and resource ('IFC model'), and distinguishes it from siblings by specifying it validates against IDS specifications. It explicitly mentions leveraging IfcTester's capabilities, which further clarifies its unique function compared to other tools like 'validate_ids' or 'create_ids'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by stating it validates 'against the current session's IDS specifications,' suggesting it should be used after IDS specifications are loaded or created. However, it does not explicitly state when to use this tool versus alternatives like 'validate_ids' or provide any exclusions or prerequisites, leaving some ambiguity for the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vinnividivicci/ifc-ids-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server