Skip to main content
Glama

edit_doc

Destructive

Edit an existing Markdown or HTML document with a precise text replacement or a full rewrite, using a base version to prevent overwriting concurrent changes. Returns the diff and new version.

Instructions

Edit an existing document (.md or .html), one of two ways. old_string + new_string replace text found exactly once (add context to make it unique; the error shows the closest passage, or each occurrence): preferred, cheap on big docs. Or content rewrites the whole file. Pass the version read_doc gave as base_version, so a change made in between is never overwritten. Committed at once, attributed to you. Returns the diff and the new version, and how the quotations it added stand against the mind's files; dry_run=true shows the diff without writing. To rename, use move_doc; to restore a past version, doc_revert.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "ai": "<ai>"
    },
    "name": "edit_doc"
  }
}

Input Schema

NameRequiredDescriptionDefault
aiYesYour AI family in lowercase (claude, chatgpt, gemini), not the model name. Attributes the change.
pathYese.g. notes/recap.md.
contentNoThe full new content (rewrite mode).
dry_runNoReturn the diff; write nothing.
new_stringNoIts replacement.
old_stringNoThe exact text to replace, unique in the doc.
base_versionNoread_doc's `version`: the edit is refused if the doc changed since. Without it, a `content` rewrite replaces the doc as it stands when it lands.
commit_messageNoWhat changed and why, specifically (e.g. 'fix the VAT rate'); omit it rather than write 'update doc'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.7.0

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the destructiveHint=true annotation, it discloses concurrency protection via base_version, that edits are committed immediately and attributed to the caller, that the operation returns the diff and new version, and that dry_run previews without writing. It even documents the failure mode for non-unique matches ('the error shows the closest passage, or each occurrence'), which the annotations do not cover.

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 mode choice is front-loaded and the sentences are dense with useful content rather than filler. Slightly dinged because the clause about 'how the quotations it added stand against the mind's files' is opaque internal jargon that costs the reader a beat.

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

Completeness4/5

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

With 8 parameters and no output schema, the description does the heavy lifting of explaining the return value (diff plus new version) and the safety model. The only gaps are the unexplained 'mind's files' clause and no mention of commit_message expectations, though the schema already documents that parameter.

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 100%, so the baseline is 3; the description earns extra credit by explaining that old_string must be unique and how to fix ambiguity, why base_version matters, and what dry_run produces. It adds little on ai and nothing on commit_message, keeping it short of a 5.

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?

States a specific verb and resource plus the accepted formats ('Edit an existing document (.md or .html)') and enumerates the two editing modes by parameter name. An agent can distinguish this from move_doc, doc_revert, or create_doc without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit mode selection guidance: old_string/new_string is 'preferred, cheap on big docs', content is the fallback for whole-file rewrites. It also routes two adjacent tasks to their proper siblings ('To rename, use move_doc; to restore a past version, doc_revert'), which is exactly the when/when-not/alternative structure that earns top marks.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.