export_ids
Export IDS documents to XML files with automatic validation against the IDS 1.0 standard using IfcTester. Converts buildingSMART specifications into compliant XML format.
Instructions
Export IDS document to XML file using IfcTester.
Uses current session automatically - no session_id parameter needed!
Args: ctx: FastMCP Context (auto-injected) output_path: File path (optional, returns XML string if not provided) validate: Whether to validate against XSD (default: True)
Returns: { "status": "exported", "xml": "...", # If no output_path "file_path": "...", # If output_path provided "validation": {"valid": true, "errors": []} }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_path | No | ||
| validate | No |
Implementation Reference
- The core handler function implementing the export_ids tool logic. Exports the current session's IDS document to an XML file or string, with optional XSD validation using IfcTester's ids module.async def export_ids( ctx: Context, output_path: Optional[str] = None, validate: bool = True ) -> Dict[str, Any]: """ Export IDS document to XML file using IfcTester. Uses current session automatically - no session_id parameter needed! Args: ctx: FastMCP Context (auto-injected) output_path: File path (optional, returns XML string if not provided) validate: Whether to validate against XSD (default: True) Returns: { "status": "exported", "xml": "...", # If no output_path "file_path": "...", # If output_path provided "validation": {"valid": true, "errors": []} } """ try: # Get IDS from session ids_obj = await get_or_create_session(ctx) validation_result = {"valid": True, "errors": []} # Export based on whether path is provided if output_path: await ctx.info(f"Exporting IDS to file: {output_path}") # Create parent directory if needed Path(output_path).parent.mkdir(parents=True, exist_ok=True) ids_obj.to_xml(output_path) # Validate if requested if validate: try: validated_ids = ids.open(output_path, validate=True) validation_result["valid"] = True except Exception as e: validation_result["valid"] = False validation_result["errors"] = [str(e)] await ctx.info(f"IDS exported successfully to {output_path}") return { "status": "exported", "file_path": output_path, "validation": validation_result } else: await ctx.info("Exporting IDS to XML string") xml_string = ids_obj.to_string() # Validate if requested if validate: try: validated_ids = ids.from_string(xml_string, validate=True) validation_result["valid"] = True except Exception as e: validation_result["valid"] = False validation_result["errors"] = [str(e)] await ctx.info("IDS exported successfully to XML string") return { "status": "exported", "xml": xml_string, "validation": validation_result } except Exception as e: await ctx.error(f"Failed to export IDS: {str(e)}") raise ToolError(f"Failed to export IDS: {str(e)}")
- src/ids_mcp_server/server.py:26-26 (registration)Registers the export_ids tool from the document module with the FastMCP server instance.mcp_server.tool(document.export_ids)
- src/ids_mcp_server/server.py:5-5 (registration)Imports the document module containing the export_ids tool for registration.from ids_mcp_server.tools import document, specification, facets, validation, restrictions
- Docstring providing input/output schema description and type hints for FastMCP tool inference.""" Export IDS document to XML file using IfcTester. Uses current session automatically - no session_id parameter needed! Args: ctx: FastMCP Context (auto-injected) output_path: File path (optional, returns XML string if not provided) validate: Whether to validate against XSD (default: True) Returns: { "status": "exported", "xml": "...", # If no output_path "file_path": "...", # If output_path provided "validation": {"valid": true, "errors": []} } """