create_document
Create a new empty HNPX document for structured fiction writing, enabling hierarchical narrative development from book planning to paragraph details.
Instructions
Create a new empty HNPX document
Args: file_path (str): Path where the new HNPX document will be created
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- src/hnpx_sdk/tools.py:18-36 (handler)The handler function that implements the create_document tool logic, generating a new HNPX document with a random book ID and saving it to the specified file path.def create_document(file_path: str) -> str: """Create a new empty HNPX document Args: file_path (str): Path where the new HNPX document will be created """ # Generate initial book ID book_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6)) # Create minimal document book = etree.Element("book", id=book_id) summary = etree.SubElement(book, "summary") summary.text = "New book" # Create tree and save tree = etree.ElementTree(book) hnpx.save_document(tree, file_path) return f"Created book with id {book_id} at {file_path}"
- src/hnpx_sdk/server.py:7-7 (registration)Registration of the create_document tool using the FastMCP app.tool() decorator.app.tool()(tools.create_document)