get_empty
Find the next empty container node within a hierarchical XML document's subtree using breadth-first search. Specify a file path and starting node ID to locate nodes without children for structured content insertion.
Instructions
Find next container node without children within a specific node's subtree (BFS order)
Args: file_path (str): Path to the HNPX document node_id (str): ID of the node to search within
Returns: str: XML representation of the next empty container node or a message if none found
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| node_id | Yes |
Implementation Reference
- src/hnpx_sdk/tools.py:53-76 (handler)The handler function implementing the 'get_empty' tool logic. It parses the HNPX document, finds the starting node, searches for the first empty container in BFS order using hnpx.find_first_empty_container, and returns its XML or a message if none found.def get_empty(file_path: str, node_id: str) -> str: """Find next container node without children within a specific node's subtree (BFS order) Args: file_path (str): Path to the HNPX document node_id (str): ID of the node to search within Returns: str: XML representation of the next empty container node or a message if none found """ tree = hnpx.parse_document(file_path) start_node = hnpx.find_node(tree, node_id) if start_node is None: raise NodeNotFoundError(node_id) empty_node = hnpx.find_first_empty_container(tree, start_node) if empty_node is None: return f"No empty containers found within node {node_id}" # Return node XML (like get_node) return etree.tostring(empty_node, encoding="unicode", method="html")
- src/hnpx_sdk/server.py:14-14 (registration)The line where the 'get_empty' tool handler is registered with the FastMCP application.app.tool()(tools.get_empty)