Skip to main content
Glama

remove_node_children

Remove all child elements from a specified parent node in HNPX XML documents to restructure narrative hierarchies during fiction writing.

Instructions

Remove all children of a node

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
node_idYes

Implementation Reference

  • The handler function that parses the HNPX document, finds the node by ID, removes all its non-summary children, saves the document, and returns a confirmation message.
    def remove_node_children(file_path: str, node_id: str) -> str: """Remove all children of a node Args: file_path (str): Path to the HNPX document node_id (str): ID of the parent node """ tree = hnpx.parse_document(file_path) node = hnpx.find_node(tree, node_id) if node is None: raise NodeNotFoundError(node_id) children_count = 0 # Remove all children except summary for child in list(node): if child.tag != "summary": node.remove(child) children_count += 1 hnpx.save_document(tree, file_path) return f"Removed {children_count} children from node {node_id}"
  • Registers the remove_node_children tool with the MCP server using the app.tool() decorator.
    app.tool()(tools.remove_node_children)

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