Skip to main content
Glama

edit_paragraph_text

Modify paragraph text content in HNPX documents by specifying file path, paragraph ID, and new text for narrative editing.

Instructions

Edit paragraph text content

Args: file_path (str): Path to the HNPX document node_id (str): ID of the paragraph node to modify new_text (str): New paragraph text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
paragraph_idYes
new_textYes

Implementation Reference

  • The handler function that implements the logic to edit the text content of a specific paragraph node in an HNPX document. It parses the document, finds the node, validates it is a paragraph, updates the text, saves the document, and returns a success message.
    def edit_paragraph_text(file_path: str, paragraph_id: str, new_text: str) -> str: """Edit paragraph text content Args: file_path (str): Path to the HNPX document node_id (str): ID of the paragraph node to modify new_text (str): New paragraph text content """ tree = hnpx.parse_document(file_path) paragraph = hnpx.find_node(tree, paragraph_id) if paragraph is None: raise NodeNotFoundError(paragraph_id) # Verify it's a paragraph element if paragraph.tag != "paragraph": raise InvalidOperationError( "edit_paragraph_text", f"Node {paragraph_id} is not a paragraph" ) # Update the paragraph text content paragraph.text = new_text hnpx.save_document(tree, file_path) return f"Updated text content for paragraph {paragraph_id}"
  • Registers the edit_paragraph_text tool with the FastMCP server using the app.tool() decorator.
    app.tool()(tools.edit_paragraph_text)

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