Skip to main content
Glama

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
NameRequiredDescriptionDefault
file_pathYes

Implementation Reference

  • 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}"
  • Registration of the create_document tool using the FastMCP app.tool() decorator.
    app.tool()(tools.create_document)

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