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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses the search algorithm (BFS order) and return behavior (XML representation or message if none found), which are valuable behavioral traits. However, it doesn't mention error handling, performance characteristics, or what constitutes a 'container node' versus other node types.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured with a clear purpose statement followed by Args and Returns sections. Every sentence earns its place: the first sentence explains what the tool does, the Args section clarifies parameters, and the Returns section specifies output. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage and an output schema exists (Returns section), the description provides good coverage. It explains the tool's purpose, parameters, and return values adequately. However, for a tree traversal tool, it could benefit from mentioning edge cases (e.g., invalid node_id, empty document) or performance notes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It explains that file_path is 'Path to the HNPX document' and node_id is 'ID of the node to search within', adding essential meaning beyond the bare schema. However, it doesn't specify format requirements (e.g., HNPX file structure, node ID format) or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Find next container node without children'), the resource ('within a specific node's subtree'), and the algorithm ('BFS order'). It distinguishes from siblings like get_children, get_subtree, and get_node by specifying the search for empty containers rather than general retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for finding empty containers in a subtree, but doesn't explicitly state when to use this tool versus alternatives like get_children (which retrieves all children) or get_subtree (which retrieves entire subtree). It provides clear context but lacks explicit exclusions or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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