Skip to main content
Glama

edit_node_attributes

Modify attributes of existing nodes in HNPX documents to update narrative elements during collaborative fiction writing.

Instructions

Modify attributes of an existing node

Args: file_path (str): Path to the HNPX document node_id (str): ID of the node to modify attributes (dict): Dictionary of attribute names and values to update

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
node_idYes
attributesYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function implementing the logic to edit attributes of a specified node in the HNPX XML document, excluding the 'id' attribute.
    def edit_node_attributes(file_path: str, node_id: str, attributes: dict) -> str:
        """Modify attributes of an existing node
    
        Args:
            file_path (str): Path to the HNPX document
            node_id (str): ID of the node to modify
            attributes (dict): Dictionary of attribute names and values to update
        """
        tree = hnpx.parse_document(file_path)
        node = hnpx.find_node(tree, node_id)
    
        if node is None:
            raise NodeNotFoundError(node_id)
    
        # Update attributes
        for key, value in attributes.items():
            if key == "id":
                raise InvalidOperationError(
                    "edit_node_attributes", "Cannot modify id attribute"
                )
    
            if value is None or value == "":
                if key in node.attrib:
                    del node.attrib[key]
            else:
                node.set(key, value)
    
        hnpx.save_document(tree, file_path)
    
        return f"Updated attributes for node {node_id}"
  • Registers the edit_node_attributes tool with the FastMCP application.
    app.tool()(tools.edit_node_attributes)
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It mentions modifying attributes but doesn't disclose critical traits like whether changes are destructive, require specific permissions, have rate limits, or what happens on error (e.g., invalid node_id). The description is minimal, offering little beyond the basic action, which is insufficient for a mutation tool with zero annotation coverage.

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 sized and front-loaded, with the purpose stated clearly in the first sentence. The Args section is structured but could be more integrated; overall, it avoids unnecessary verbosity. However, the separation into 'Args' feels slightly disjointed, and every sentence adds value without waste.

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 the tool's complexity (mutation with 3 parameters, nested objects, and an output schema), the description is minimally adequate. The output schema existence means return values needn't be explained, but the description lacks context on HNPX documents, attribute types, or error handling. With no annotations and low schema coverage, it should do more to be complete, but it meets a basic threshold by stating the action and parameters.

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

Parameters3/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 but only partially does. It lists parameters (file_path, node_id, attributes) and briefly explains attributes as a dictionary of names and values to update, adding some meaning beyond the schema's type definitions. However, it doesn't detail parameter formats (e.g., what node_id looks like, valid attribute names), leaving gaps. With 0% coverage, this is a baseline effort that doesn't fully address the deficiency.

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 ('Modify attributes') and target ('existing node'), distinguishing it from creation tools (e.g., create_beat, create_chapter) and other edit tools (e.g., edit_paragraph_text). However, it doesn't specify what types of attributes can be modified or the node's context (e.g., HNPX document structure), leaving some ambiguity compared to siblings like edit_summary.

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?

No explicit guidance on when to use this tool versus alternatives is provided. For instance, it doesn't clarify when to choose edit_node_attributes over edit_paragraph_text for text changes or how it differs from move_nodes for structural modifications. The description only implies usage by stating it modifies attributes of an existing node, without context or exclusions.

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