get_root_id
Retrieve the root node ID from HNPX XML documents to enable structured fiction writing and hierarchical narrative development.
Instructions
Get ID of the book node (document root)
Args: file_path (str): Path to the HNPX document
Returns: str: ID of the book node
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- src/hnpx_sdk/tools.py:39-51 (handler)The main handler function for the get_root_id tool. It parses the HNPX XML document from the given file_path and returns the 'id' attribute of the root 'book' element.def get_root_id(file_path: str) -> str: """Get ID of the book node (document root) Args: file_path (str): Path to the HNPX document Returns: str: ID of the book node """ tree = hnpx.parse_document(file_path) root = tree.getroot() return root.get("id")
- src/hnpx_sdk/server.py:10-10 (registration)Registers the get_root_id function as an MCP tool using FastMCP's app.tool() decorator.app.tool()(tools.get_root_id)