Skip to main content
Glama

create_sequence

Add a sequence element to HNPX fiction documents by specifying location, summary, time, and point-of-view within a chapter structure.

Instructions

Create a new sequence element

Args: file_path (str): Path to the HNPX document parent_id (str): ID of the parent chapter element location (str): Location description summary (str): Sequence summary text time (Optional[str]): Time indicator (e.g., "night", "next day", "flashback") pov (Optional[str]): Point-of-view character identifier

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
parent_idYes
locationYes
summaryYes
timeNo
povNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the create_sequence tool. It parses the HNPX document, builds attributes for the new sequence element, uses the _create_element helper to add it under the specified parent, saves the document, and returns the new element's ID.
    def create_sequence(
        file_path: str,
        parent_id: str,
        location: str,
        summary: str,
        time: Optional[str] = None,
        pov: Optional[str] = None,
    ) -> str:
        """Create a new sequence element
    
        Args:
            file_path (str): Path to the HNPX document
            parent_id (str): ID of the parent chapter element
            location (str): Location description
            summary (str): Sequence summary text
            time (Optional[str]): Time indicator (e.g., "night", "next day", "flashback")
            pov (Optional[str]): Point-of-view character identifier
        """
        tree = hnpx.parse_document(file_path)
    
        attributes = {"location": location}
        if time:
            attributes["time"] = time
        if pov:
            attributes["pov"] = pov
    
        new_id = _create_element(tree, parent_id, "sequence", attributes, summary)
    
        hnpx.save_document(tree, file_path)
    
        return f"Created sequence with id {new_id}"
  • Registers the create_sequence function as an MCP tool in the FastMCP application.
    app.tool()(tools.create_sequence)
  • Shared helper function called by create_sequence (and other create_* functions) to perform hierarchy validation, 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 full burden for behavioral disclosure. It states this is a creation operation but doesn't mention permissions needed, whether it's idempotent, what happens on failure, or what the output contains. The description adds minimal behavioral context beyond the basic 'create' action.

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

Conciseness3/5

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

The description is appropriately sized but not optimally structured. The purpose statement is clear but brief, and the parameter documentation is comprehensive but presented as a simple list without prioritization or grouping of required vs optional parameters.

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 a creation tool with 6 parameters, 0% schema coverage, no annotations, but with an output schema present, the description is moderately complete. It documents all parameters well but lacks behavioral context and usage guidance. The presence of an output schema means the description doesn't need to explain return values.

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 for 6 parameters, the description compensates well by documenting all parameters with clear explanations. It adds meaning beyond the schema by explaining what each parameter represents (e.g., 'Path to the HNPX document', 'ID of the parent chapter element', 'Time indicator (e.g., "night", "next day", "flashback")').

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 tool creates a 'new sequence element' with a specific verb+resource combination. It distinguishes from siblings like 'create_chapter' or 'create_paragraph' by specifying it creates a 'sequence' element, though it doesn't explicitly contrast with all sibling creation tools.

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_beat'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to infer usage from parameter names alone.

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