Skip to main content
Glama

edit_summary

Modify summary text for specific nodes in HNPX documents to update narrative content during collaborative fiction writing.

Instructions

Edit summary text of a node

Args: file_path (str): Path to the HNPX document node_id (str): ID of the node containing the summary new_summary (str): New summary text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
node_idYes
new_summaryYes

Implementation Reference

  • The core handler function that implements the edit_summary tool. It parses the HNPX document, locates the specified node, validates it (not a paragraph), updates or creates the summary element with new text, saves the document, and returns a confirmation message.
    def edit_summary(file_path: str, node_id: str, new_summary: str) -> str: """Edit summary text of a node Args: file_path (str): Path to the HNPX document node_id (str): ID of the node containing the summary new_summary (str): New summary text content """ tree = hnpx.parse_document(file_path) node = hnpx.find_node(tree, node_id) if node is None: raise NodeNotFoundError(node_id) if node.tag == "paragraph": raise InvalidOperationError( "edit_summary", "Paragraphs can't contain summaries" ) # Find the summary child element summary_elem = node.find("summary") if summary_elem is None: # Create summary if it doesn't exist (shouldn't happen with valid HNPX) summary_elem = etree.SubElement(node, "summary") # Update the summary text summary_elem.text = new_summary hnpx.save_document(tree, file_path) return f"Updated summary for node {node_id}"
  • The line where the edit_summary tool is registered with the FastMCP application using the app.tool() decorator.
    app.tool()(tools.edit_summary)

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