Skip to main content
Glama

create_beat

Add a narrative beat to a hierarchical fiction document by specifying parent sequence and summary text for structured story development.

Instructions

Create a new beat element

Args: file_path (str): Path to the HNPX document parent_id (str): ID of the parent sequence element summary (str): Beat summary text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
parent_idYes
summaryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function that parses the HNPX document, creates a new 'beat' element under the specified parent using the _create_element helper, saves the document, and returns the new beat's ID.
    def create_beat(file_path: str, parent_id: str, summary: str) -> str:
        """Create a new beat element
    
        Args:
            file_path (str): Path to the HNPX document
            parent_id (str): ID of the parent sequence element
            summary (str): Beat summary text
        """
        tree = hnpx.parse_document(file_path)
    
        new_id = _create_element(tree, parent_id, "beat", {}, summary)
    
        hnpx.save_document(tree, file_path)
    
        return f"Created beat with id {new_id}"
  • Registers the create_beat function as a tool in the FastMCP application.
    app.tool()(tools.create_beat)
  • Shared helper function used by create_beat (and other create_* functions) to validate hierarchy, generate unique ID, create the element with attributes and summary, and return the new ID.
    def _create_element(
        tree: etree.ElementTree,
        parent_id: str,
        element_tag: str,
        attributes: dict,
        summary_text: str,
    ) -> str:
        """Generic element creation helper"""
        parent = hnpx.find_node(tree, parent_id)
        if parent is None:
            raise NodeNotFoundError(parent_id)
    
        # Check hierarchy
        valid_hierarchy = {
            "book": ["chapter"],
            "chapter": ["sequence"],
            "sequence": ["beat"],
            "beat": ["paragraph"],
        }
    
        if (
            parent.tag not in valid_hierarchy
            or element_tag not in valid_hierarchy[parent.tag]
        ):
            raise InvalidHierarchyError(parent.tag, element_tag)
    
        # Generate unique ID
        existing_ids = hnpx.get_all_ids(tree)
        new_id = hnpx.generate_unique_id(existing_ids)
        attributes["id"] = new_id
    
        # Create element
        element = etree.SubElement(parent, element_tag, **attributes)
        summary = etree.SubElement(element, "summary")
        summary.text = summary_text
    
        return new_id
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't address important behavioral aspects like: what permissions are required, whether the creation is reversible, what happens if the parent_id doesn't exist, or what the tool returns (though an output schema exists). The description is minimal and lacks behavioral context.

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 appropriately concise with a clear two-part structure: a purpose statement followed by parameter descriptions. Every sentence serves a purpose, though the parameter descriptions could be more informative. The information is front-loaded with the main action first.

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 that this is a creation/mutation tool with no annotations, 3 parameters with 0% schema coverage, but with an output schema present, the description is moderately complete. The presence of an output schema means the description doesn't need to explain return values, but it should do more to explain the tool's behavior, parameter expectations, and differentiation from sibling tools.

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

Parameters2/5

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

The schema description coverage is 0%, so the schema provides no parameter documentation. The description includes an 'Args' section that names and briefly describes each parameter, which adds value beyond the bare schema. However, the descriptions are minimal ('Path to the HNPX document', 'ID of the parent sequence element', 'Beat summary text') and don't explain format expectations, constraints, or examples.

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') and resource ('new beat element'), which is specific and unambiguous. However, it doesn't differentiate this tool from sibling tools like 'create_chapter', 'create_paragraph', or 'create_sequence', which all appear to create different types of elements in the same document system.

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 'create_chapter' or 'create_paragraph'. It mentions that a beat is created within a parent sequence element, but doesn't explain what distinguishes a 'beat' from other element types or when this specific creation tool is appropriate.

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