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

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)

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