add_attribute_facet
Add attribute requirements to buildingSMART IDS specifications to define mandatory, optional, or prohibited properties for compliance validation.
Instructions
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"}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec_id | Yes | ||
| location | Yes | ||
| attribute_name | Yes | ||
| value | No | ||
| cardinality | No | required |
Implementation Reference
- The core handler function that implements the logic for adding an attribute facet to an IDS specification. It creates an Attribute object using IfcTester's ids library, appends it to the appropriate section (applicability or requirements), and returns a success status.async def add_attribute_facet( spec_id: str, location: str, attribute_name: str, ctx: Context, value: Optional[str] = None, cardinality: str = "required" ) -> Dict[str, Any]: """ 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"} """ try: ids_obj = await get_or_create_session(ctx) spec = _find_specification(ids_obj, spec_id) await ctx.info(f"Adding attribute facet: {attribute_name} to {spec_id}") # Create attribute facet using IfcTester attr = ids.Attribute( name=attribute_name, value=value, cardinality=cardinality if location == "requirements" else None ) # Add to appropriate section if location == "applicability": spec.applicability.append(attr) elif location == "requirements": spec.requirements.append(attr) else: raise ToolError(f"Invalid location: {location}") await ctx.info(f"Attribute facet added: {attribute_name}") return { "status": "added", "facet_type": "attribute", "spec_id": spec_id } except ToolError: raise except Exception as e: await ctx.error(f"Failed to add attribute facet: {str(e)}") raise ToolError(f"Failed to add attribute facet: {str(e)}")
- src/ids_mcp_server/server.py:35-35 (registration)Registration of the add_attribute_facet tool in the FastMCP server instance.mcp_server.tool(facets.add_attribute_facet)