Skip to main content
Glama

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
NameRequiredDescriptionDefault
file_pathYes
node_idYes

Implementation Reference

  • 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")
  • The line where the 'get_empty' tool handler is registered with the FastMCP application.
    app.tool()(tools.get_empty)

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/mozhaa/hnpx-sdk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server