Skip to main content
Glama

edit_document

Replace specific text in documents by identifying exact strings to modify and inserting new content. Use this tool to update document content through precise text substitution.

Instructions

Edit a document by replacing a string in the documents content with a new string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYesId of the document that will be edited
old_strYesThe text to replace. Must match exactly, including whitespace.
new_strYesThe new text to insert in place of the old text.

Implementation Reference

  • The edit_document function that executes the tool logic. It takes doc_id, old_str, and new_str parameters, validates the document exists, performs string replacement on the document content, and returns the updated content.
    def edit_document(
        doc_id: str = Field(description="Id of the document that will be edited"),
        old_str: str = Field(description="The text to replace. Must match exactly, including whitespace."),
        new_str: str = Field(description="The new text to insert in place of the old text.")
    ):
        if doc_id not in docs:
            raise ValueError(f"Doc with id {doc_id} not found")
        
        docs[doc_id] = docs[doc_id].replace(old_str, new_str)
        return docs[doc_id]
  • mcp_server.py:29-32 (registration)
    Registration of the edit_document tool using the @mcp.tool decorator with name='edit_document' and description.
    @mcp.tool(
        name="edit_document",
        description="Edit a document by replacing a string in the documents content with a new string."
    )
  • Input schema definitions using Pydantic Field() for the three parameters: doc_id (document to edit), old_str (text to replace), and new_str (replacement text), each with descriptive metadata.
    doc_id: str = Field(description="Id of the document that will be edited"),
    old_str: str = Field(description="The text to replace. Must match exactly, including whitespace."),
    new_str: str = Field(description="The new text to insert in place of the old text.")
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 tool edits by replacement, implying mutation, but lacks details on permissions, error handling (e.g., if old_str isn't found), side effects, or rate limits. This is a significant gap for a mutation tool.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

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

Completeness2/5

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

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens on success (e.g., returns updated content?), failure modes, or behavioral traits like idempotency, leaving the agent with insufficient context for reliable use.

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 100%, so the schema already documents all three parameters (doc_id, old_str, new_str) with clear descriptions. The description adds no additional meaning beyond what's in the schema, such as examples or edge cases, meeting the baseline for high coverage.

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 verb ('edit') and resource ('document'), specifying the action as 'replacing a string in the document's content with a new string.' This distinguishes it from siblings like 'read_doc_contents' (read-only) and 'return all the docs' (listing), though it doesn't explicitly mention these distinctions.

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 guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing edit permissions), exclusions (e.g., not for creating documents), or compare to sibling tools like 'read_doc_contents' for viewing content.

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/mparth14/MCP-anthropic'

If you have feedback or need assistance with the MCP directory API, please join our Discord server