add_attribute_facet
Add attribute facets to IDS specifications to define required, optional, or prohibited attributes with specific values for applicability or requirements sections.
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 executes the tool logic: retrieves the IDS session and specification, creates an Attribute facet using the ifctester.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)Registers the add_attribute_facet handler as a tool with the FastMCP server instance.mcp_server.tool(facets.add_attribute_facet)