Skip to main content
Glama

remove_nodes

Permanently delete multiple nodes and all their descendants from HNPX hierarchical fiction documents to manage narrative structure.

Instructions

Permanently remove multiple nodes and all their descendants

Args: file_path (str): Path to the HNPX document node_ids (list): List of node IDs to remove

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
node_idsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function that implements the remove_nodes tool. It parses the HNPX document, finds and removes the specified nodes (preventing root removal), saves the changes, and returns a confirmation message.
    def remove_nodes(file_path: str, node_ids: list) -> str:
        """Permanently remove multiple nodes and all their descendants
    
        Args:
            file_path (str): Path to the HNPX document
            node_ids (list): List of node IDs to remove
        """
        tree = hnpx.parse_document(file_path)
    
        nodes_removed = 0
        for node_id in node_ids:
            node = hnpx.find_node(tree, node_id)
    
            if node is None:
                raise NodeNotFoundError(node_id)
    
            # Check if trying to remove root
            if node.tag == "book":
                raise InvalidOperationError("remove_nodes", "Cannot remove book element")
    
            # Remove node
            parent = node.getparent()
            parent.remove(node)
            nodes_removed += 1
    
        hnpx.save_document(tree, file_path)
    
        return f"Removed {nodes_removed} nodes and their descendants"
  • Registration of the remove_nodes tool in the FastMCP application.
    app.tool()(tools.remove_nodes)
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. It states the action is 'permanent' and removes 'descendants', which is valuable. However, it omits critical details: whether this requires specific permissions, what happens on failure (e.g., partial removal), if changes are reversible, or any rate limits. For a destructive operation, this is a significant gap.

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

Conciseness5/5

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

The description is highly efficient: a single sentence states the purpose, followed by a clear 'Args:' section listing parameters with brief explanations. Every element earns its place—no redundancy or fluff. It's front-loaded with the core action and structured for quick parsing.

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 destructive tool with no annotations, 0% schema coverage, but an output schema (which handles return values), the description is partially complete. It covers the purpose and parameters well but lacks behavioral context (e.g., safety, error handling) and usage guidelines. For a high-stakes operation like permanent removal, more guidance is warranted despite the output schema.

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?

Schema description coverage is 0%, so the description must compensate. It explicitly documents both parameters: 'file_path' as a path to an HNPX document and 'node_ids' as a list of node IDs to remove. This adds essential meaning beyond the bare schema, though it could specify format details (e.g., ID types or path syntax). With 0% coverage and 2 parameters, this is strong but not exhaustive.

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

Purpose5/5

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

The description clearly states the specific action ('permanently remove'), the resource ('multiple nodes and all their descendants'), and distinguishes from siblings like 'remove_node_children' (which only removes children) and 'move_nodes' (which relocates rather than deletes). The verb+resource combination is precise and unambiguous.

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 'remove_node_children' (for partial removal) or 'edit_node_attributes' (for modification instead of deletion). It lacks context about prerequisites (e.g., whether nodes must exist) or exclusions (e.g., not for single-node removal if a simpler tool exists).

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