Skip to main content
Glama

get_path

Retrieve the hierarchical path from document root to a specified node in HNPX XML documents for structured fiction writing.

Instructions

Return hierarchical path from document root to specified node

Args: file_path (str): Path to the HNPX document node_id (str): ID of the target node

Returns: str: Concatenated XML representation of all nodes in the path from root to target

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
node_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_path' tool. It parses the HNPX XML document, locates the specified node by ID, traverses up to the root collecting all ancestors, and returns their concatenated HTML-formatted XML representations separated by newlines.
    def get_path(file_path: str, node_id: str) -> str:
        """Return hierarchical path from document root to specified node
    
        Args:
            file_path (str): Path to the HNPX document
            node_id (str): ID of the target node
    
        Returns:
            str: Concatenated XML representation of all nodes in the path from root to target
        """
        tree = hnpx.parse_document(file_path)
        node = hnpx.find_node(tree, node_id)
    
        if node is None:
            raise NodeNotFoundError(node_id)
    
        # Collect ancestors
        ancestors = []
        current = node
        while current is not None:
            ancestors.insert(0, current)
            current = current.getparent()
    
        # Return concatenated XML of all ancestors
        path_xml = []
        for ancestor in ancestors:
            path_xml.append(etree.tostring(ancestor, encoding="unicode", method="html"))
    
        return "\n".join(path_xml)
  • The registration of the 'get_path' tool in the FastMCP application using the app.tool() decorator.
    app.tool()(tools.get_path)
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the return type (concatenated XML representation) and the path scope (from root to target), but lacks details on error handling, performance, or side effects. It adequately describes the core behavior without contradictions.

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 front-loaded with the core purpose, followed by structured Args and Returns sections. Every sentence adds value, with no wasted words, making it efficient and easy to parse.

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 the tool's moderate complexity (2 parameters, no annotations), the description is mostly complete: it explains purpose, parameters, and return value. However, it lacks guidance on usage versus siblings and behavioral details like error cases. The presence of an output schema (Returns: str) reduces the need for return value explanation.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining both parameters: file_path as 'Path to the HNPX document' and node_id as 'ID of the target node'. This adds essential meaning beyond the bare schema types.

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 tool's purpose with a specific verb ('Return') and resource ('hierarchical path from document root to specified node'), and it distinguishes from siblings like get_node, get_subtree, get_children, and get_root_id by specifying it returns a concatenated path rather than a single node or subtree.

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

Usage Guidelines3/5

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

The description implies usage when needing a hierarchical path to a node, but does not explicitly state when to use this tool versus alternatives like get_node (for a single node) or get_subtree (for a subtree). No exclusions or prerequisites are mentioned.

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