Skip to main content
Glama

create_paragraph

Add paragraph elements to HNPX fiction documents with configurable narrative modes including narration, dialogue, and internal monologue.

Instructions

Create a new paragraph element

Args: file_path (str): Path to the HNPX document parent_id (str): ID of the parent beat element text (str): Paragraph text content mode (str): Narrative mode - one of: "narration" (default), "dialogue", "internal" char (Optional[str]): Character identifier (required when mode="dialogue")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
parent_idYes
textYes
modeNonarration
charNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the create_paragraph tool. It parses the HNPX document, validates the parent is a beat, generates a unique ID, creates a paragraph element with mode and optional char attributes, sets the text content, saves the document, and returns a confirmation message.
    def create_paragraph(
        file_path: str,
        parent_id: str,
        text: str,
        mode: str = "narration",
        char: Optional[str] = None,
    ) -> str:
        """Create a new paragraph element
    
        Args:
            file_path (str): Path to the HNPX document
            parent_id (str): ID of the parent beat element
            text (str): Paragraph text content
            mode (str): Narrative mode - one of: "narration" (default), "dialogue", "internal"
            char (Optional[str]): Character identifier (required when mode="dialogue")
        """
        tree = hnpx.parse_document(file_path)
    
        attributes = {"mode": mode}
        if char:
            attributes["char"] = char
        elif mode == "dialogue":
            raise MissingAttributeError("char")
    
        # Create the paragraph with text content
        parent = hnpx.find_node(tree, parent_id)
        if parent is None:
            raise NodeNotFoundError(parent_id)
    
        if parent.tag != "beat":
            raise InvalidParentError(parent.tag, "beat")
    
        existing_ids = hnpx.get_all_ids(tree)
        new_id = hnpx.generate_unique_id(existing_ids)
        attributes["id"] = new_id
    
        paragraph = etree.SubElement(parent, "paragraph", **attributes)
        paragraph.text = text
    
        hnpx.save_document(tree, file_path)
    
        return f"Created paragraph with id {new_id}"
  • Registers the create_paragraph function as an MCP tool using the fastmcp app.tool() decorator.
    app.tool()(tools.create_paragraph)
  • Imports the tools module containing the create_paragraph function.
    from . import tools
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a creation operation but doesn't address permissions, whether it modifies the document in-place, error handling, or what happens if parent_id is invalid. For a mutation tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by parameter explanations. Each sentence adds value, though the parameter explanations could be slightly more integrated with the main description rather than appearing as a separate 'Args' section.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations but with an output schema (which handles return values), the description covers parameters well but lacks behavioral context about the creation operation's effects, error conditions, and relationship to sibling tools. It's minimally adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining all 5 parameters: file_path identifies the document, parent_id specifies location, text provides content, mode defines narrative type with enum values, and char clarifies conditional requirement. This adds substantial meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new paragraph element') and identifies the resource ('paragraph element'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this from sibling tools like 'edit_paragraph_text' or 'create_beat', which would require a more specific comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'edit_paragraph_text' for modifying existing paragraphs or 'create_beat' for other element types. It mentions parameter dependencies (char required for dialogue mode) but offers no broader contextual advice for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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