add_entity_facet
Add entity facets to IDS specifications to define which IFC building elements are included in applicability or requirements sections, ensuring compliance with IDS 1.0 standards.
Instructions
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
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec_id | Yes | ||
| location | Yes | ||
| entity_name | Yes | ||
| predefined_type | No | ||
| cardinality | No | required |
Implementation Reference
- src/ids_mcp_server/tools/facets.py:16-81 (handler)The primary handler function implementing the 'add_entity_facet' tool. It validates the location, creates an IDS Entity facet using the ifctester library, and appends it to the appropriate section (applicability or requirements) of the specified IDS specification.async def add_entity_facet( spec_id: str, location: str, entity_name: str, ctx: Context, predefined_type: Optional[str] = None, cardinality: str = "required" ) -> Dict[str, Any]: """ 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 """ try: ids_obj = await get_or_create_session(ctx) spec = _find_specification(ids_obj, spec_id) # EARLY VALIDATION: Check IDS 1.0 constraint validate_single_entity_in_applicability(spec, location) await ctx.info(f"Adding entity facet: {entity_name} to {spec_id}") # Create entity facet using IfcTester entity = ids.Entity( name=entity_name.upper(), predefinedType=predefined_type ) # Add to appropriate section if location == "applicability": spec.applicability.append(entity) elif location == "requirements": # Note: Entity facets in requirements don't have cardinality in IDS spec.requirements.append(entity) else: raise ToolError(f"Invalid location: {location}. Must be 'applicability' or 'requirements'") await ctx.info(f"Entity facet added: {entity_name}") return { "status": "added", "facet_type": "entity", "spec_id": spec_id } except ToolError: raise except Exception as e: await ctx.error(f"Failed to add entity facet: {str(e)}") raise ToolError(f"Failed to add entity facet: {str(e)}")
- src/ids_mcp_server/server.py:33-33 (registration)The line where the add_entity_facet tool is registered with the FastMCP server instance.mcp_server.tool(facets.add_entity_facet)
- Type hints in the function signature define the input schema for the tool (spec_id, location, entity_name, predefined_type, cardinality), with ctx auto-injected by FastMCP. Returns a dict with status info.async def add_entity_facet( spec_id: str, location: str, entity_name: str, ctx: Context, predefined_type: Optional[str] = None, cardinality: str = "required" ) -> Dict[str, Any]: