Skip to main content
Glama

get_node

Retrieve XML representation of a specific node from HNPX documents for hierarchical fiction writing, extracting individual narrative elements with attributes and summary data.

Instructions

Retrieve XML representation of a specific node (without descendants)

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

Returns: str: XML representation of the node with its attributes and summary child only

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
node_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_node' tool. It parses the HNPX XML document, locates the node by ID, removes all children except the summary, and returns the node's XML string.
    def get_node(file_path: str, node_id: str) -> str:
        """Retrieve XML representation of a specific node (without descendants)
    
        Args:
            file_path (str): Path to the HNPX document
            node_id (str): ID of the node to retrieve
    
        Returns:
            str: XML representation of the node with its attributes and summary child only
        """
        tree = hnpx.parse_document(file_path)
        node = hnpx.find_node(tree, node_id)
    
        if node is None:
            raise NodeNotFoundError(node_id)
    
        _remove_children(node)
    
        # Return node with all attributes and summary child
        return etree.tostring(node, encoding="unicode", method="html")
  • Registers the get_node function as an MCP tool using FastMCP's app.tool() decorator.
    app.tool()(tools.get_node)
  • Helper function used by get_node to strip all child elements except the 'summary' from the retrieved node.
    def _remove_children(node: Any) -> None:
        for child in node:
            if child.tag != "summary":
                node.remove(child)
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the core behavior (retrieves XML representation of a specific node without descendants) and specifies what is included in the return (attributes and summary child only). However, it lacks details on potential errors (e.g., invalid file_path or node_id), performance aspects, or any side effects, which are important for a read operation in a document system.

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 well-structured and front-loaded with the core purpose in the first sentence, followed by clear sections for Args and Returns. Every sentence adds value without redundancy, making it efficient and easy to parse for an AI agent.

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 (a read operation with 2 parameters), no annotations, and an output schema present (which handles return values), the description is largely complete. It covers purpose, parameters, and return scope adequately. However, it could benefit from more behavioral context (e.g., error handling or performance notes) to fully compensate for the lack of annotations.

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?

The schema description coverage is 0%, so the description must compensate. It adds meaningful semantics by explaining that file_path is 'Path to the HNPX document' and node_id is 'ID of the node to retrieve', which clarifies the purpose of each parameter beyond their names. However, it does not provide format details (e.g., expected path format or ID structure), leaving some ambiguity.

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 ('Retrieve XML representation') and resource ('a specific node'), explicitly distinguishes it from siblings by specifying 'without descendants' (unlike get_subtree or get_children), and clarifies the scope of what is returned (node with attributes and summary child only).

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 provides clear context for when to use this tool (to retrieve a single node's XML without descendants), but does not explicitly mention when not to use it or name specific alternatives (e.g., get_subtree for nodes with descendants, get_children for child nodes). However, the distinction from siblings is implied through the 'without descendants' clause.

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