Skip to main content
Glama

Edit, append, compact, or restore a doc

doc_edit
Destructive

Edit or restore existing documents and task pages by patching text, appending sections, compacting notes, or undoing changes; use table and task-note tools for tables and logs.

Instructions

Change or undo an existing doc or task page; tables via doc_edit_table, task logs via task_note. Prefer patch (old or section/from+to+print) over rewrite. append adds at the end, under under, or to assistant notes (task ID)/Diary.

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": {
      "doc": "<doc>",
      "mode": "<mode>"
    },
    "name": "doc_edit"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoFor `patch`: 1-based end line (defaults to EOF; with `from` only)
docYesDoc ID, task-page filename, or task ID (for `append`, `digest_task_notes`, `restore`)
oldNoFor `patch`: unique verbatim passage to replace (not with `section`/`from`)
echoNoReturn lines around the change (`patch`/`append`)
fromNoFor `patch`: 1-based start line (requires `print`)
modeYes`digest_task_notes` compacts assistant notes
printNoCard/read fingerprint; required for `rewrite`, `compact`, positional `patch`
underNoFor `append`: exact heading text to append under
contentNoNew text for every mode but `restore` ("" deletes in `patch`; <=6,000 for `digest_task_notes`)
sectionNoFor `patch`: 0-based heading index from card (requires `print`)
versionNoFor `restore`: target version ID from `workspace_read(view="versions")`
even_if_moreNoFor `restore`: also undo newer edits, once read
person_askedNoFor `compact`: the person asked, on a doc they began
keep_compactionNoConfirm keeping prior compaction on user request

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv1.52.0
    • changedInput schema / properties / content / description
      Previous value: -"New text for `patch` (\"\" deletes), `append`, `rewrite`, `compact`, `digest_task_notes`"New value: +"New text for every mode but `restore` (\"\" deletes in `patch`; <=6,000 for `digest_task_notes`)"
    • changedInput schema / properties / even_if_more / description
      Previous value: -"For `restore`: revert past newer edits after inspecting them"New value: +"For `restore`: also undo newer edits, once read"
    • changedInput schema / properties / mode / description
      Previous value: -"Edit operation"New value: +"`digest_task_notes` compacts assistant notes"
    • changedInput schema / properties / person_asked / description
      Previous value: -"For `compact`: user explicitly asked to compact a doc they began"New value: +"For `compact`: the person asked, on a doc they began"
  2. Added

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, non-idempotent, closed-world, so the safety bar is partly covered. The description adds genuinely non-structured behavior: that `append` targets the end, an `under` heading, or assistant notes/Diary, and that `patch` is the safer default over the blanket-overwriting `rewrite`. It stops short of saying what `rewrite`/`compact` destroy or that restore requires a prior read.

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?

Three tight, front-loaded sentences with no filler; the sibling exclusions and the patch-over-rewrite preference come before any mode detail. The telegraphic style (bare mode names, backticked tokens) pushes some cognitive load onto the reader and never mentions `compact` or `digest_task_notes` in prose.

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?

For a destructive, 14-parameter, six-mode tool with no output schema, the description covers patching and appending but leaves `compact` and `digest_task_notes` to the schema field text and says nothing about what a caller gets back or how large/irreversible a `rewrite` is. Adequate to select the tool, thin for invoking the less common modes safely.

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 coverage is 100%, so baseline is 3, but the description adds relational meaning the per-field descriptions do not: which `patch` argument combinations are alternatives (`old` vs `section`/`from`+`to`+`print`) and that `append` can address a task ID rather than a doc. It leaves `compact`, `echo`, `even_if_more`, and `keep_compaction` explained only by the schema.

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 concrete verb pair ('change or undo') plus the resource ('existing doc or task page') and immediately scopes out non-covered cases by naming `doc_edit_table` for tables and `task_note` for task logs. An agent can distinguish this from every relevant sibling without opening a 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 routing rules ('tables via doc_edit_table, task logs via task_note') and an intra-tool preference ('Prefer `patch` ... over `rewrite`') with the argument shapes each mode requires. This is exactly the when-to-use/when-to-use-something-else guidance the dimension asks for.

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