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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| node_id | Yes | ||
| new_summary | Yes |
Implementation Reference
- src/hnpx_sdk/tools.py:487-517 (handler)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}"
- src/hnpx_sdk/server.py:24-24 (registration)The line where the edit_summary tool is registered with the FastMCP application using the app.tool() decorator.app.tool()(tools.edit_summary)