Skip to main content
Glama

add_length_restriction

Define character length limits for parameters in IDS specifications to enforce data validation requirements and ensure compliance with buildingSMART standards.

Instructions

Add string length restriction.

Args: spec_id: Specification identifier or name facet_index: Index of facet in location (0-based) parameter_name: Which parameter to restrict (e.g., "value") base_type: XSD base type (e.g., "xs:string") ctx: FastMCP Context (auto-injected) location: "applicability" or "requirements" (default: "requirements") length: Exact length min_length: Minimum length max_length: Maximum length

Returns: {"status": "added", "restriction_type": "length", "spec_id": "S1"}

Example: Add length restriction to attribute value: Tag must be between 5 and 50 characters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spec_idYes
facet_indexYes
parameter_nameYes
base_typeYes
locationNorequirements
lengthNo
min_lengthNo
max_lengthNo

Implementation Reference

  • The core handler function that implements the 'add_length_restriction' tool. It adds length-based restrictions (exact length, min_length, max_length) to a specified parameter in an IDS specification facet using the IfcTester library.
    async def add_length_restriction( spec_id: str, facet_index: int, parameter_name: str, base_type: str, ctx: Context, location: str = "requirements", length: Optional[int] = None, min_length: Optional[int] = None, max_length: Optional[int] = None ) -> Dict[str, Any]: """ Add string length restriction. Args: spec_id: Specification identifier or name facet_index: Index of facet in location (0-based) parameter_name: Which parameter to restrict (e.g., "value") base_type: XSD base type (e.g., "xs:string") ctx: FastMCP Context (auto-injected) location: "applicability" or "requirements" (default: "requirements") length: Exact length min_length: Minimum length max_length: Maximum length Returns: {"status": "added", "restriction_type": "length", "spec_id": "S1"} Example: Add length restriction to attribute value: Tag must be between 5 and 50 characters """ try: ids_obj = await get_or_create_session(ctx) spec = _find_specification(ids_obj, spec_id) await ctx.info(f"Adding length restriction to {spec_id}, facet {facet_index}") # Get the facet facet = _get_facet_from_spec(spec, location, facet_index) # Build length parameters length_params = {} if length is not None: length_params["length"] = length if min_length is not None: length_params["minLength"] = min_length if max_length is not None: length_params["maxLength"] = max_length # Create length restriction using IfcTester # Normalize base type (remove 'xs:' prefix if present) normalized_base = _normalize_base_type(base_type) restriction = ids.Restriction( base=normalized_base, options=length_params ) # Apply restriction to the parameter _apply_restriction_to_facet(facet, parameter_name, restriction) await ctx.info(f"Length restriction added: {length_params}") return { "status": "added", "restriction_type": "length", "spec_id": spec_id, "facet_index": facet_index, "parameter": parameter_name, "constraints": length_params } except ToolError: raise except Exception as e: await ctx.error(f"Failed to add length restriction: {str(e)}") raise ToolError(f"Failed to add length restriction: {str(e)}")
  • Registers the 'add_length_restriction' tool function with the MCP server instance.
    mcp_server.tool(restrictions.add_length_restriction)

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