get_children
Retrieve direct child nodes from a specified parent in HNPX XML documents to support hierarchical fiction writing and narrative expansion.
Instructions
Retrieve immediate child nodes of a specified parent
Args: file_path (str): Path to the HNPX document node_id (str): ID of the parent node
Returns: str: Concatenated XML representation of all direct child nodes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| node_id | Yes |
Implementation Reference
- src/hnpx_sdk/tools.py:169-193 (handler)The main handler function for the 'get_children' tool. It parses the HNPX document, finds the parent node by ID, collects XML of direct children (excluding summary), removes their children, and returns concatenated XML strings.def get_children(file_path: str, node_id: str) -> str: """Retrieve immediate child nodes of a specified parent Args: file_path (str): Path to the HNPX document node_id (str): ID of the parent node Returns: str: Concatenated XML representation of all direct child nodes """ tree = hnpx.parse_document(file_path) parent = hnpx.find_node(tree, node_id) if parent is None: raise NodeNotFoundError(node_id) # Return concatenated XML of all direct children children_xml = [] for child in parent: if child.tag == "summary": continue _remove_children(child) children_xml.append(etree.tostring(child, encoding="unicode", method="html")) return "\n".join(children_xml)
- src/hnpx_sdk/server.py:13-13 (registration)Registers the get_children function as a tool in the FastMCP application.app.tool()(tools.get_children)