Skip to main content
Glama

Edit Document

patch-document
Destructive

Applies one or more edit operations, in order, to an existing ODocs.co document; people who have it open see each edit in real time. Returns { id, version, ok }, plus a warning when the author name was changed. Two kinds of operation: text-anchored (insert-after / insert-before / replace-text / delete-text), where the server finds the given exact text and resolves it to a position, so no character offsets are needed; and position-based (insert / delete / replace) at an exact character offset. expectedVersion enables conflict detection: if the document changed since that version, the patch is refused with 409 and nothing is applied. Operations are not atomic: they apply one at a time to the live document and are not rolled back. When one fails, the operations before it stay applied (and visible), and the 400 body reports appliedOps: N, the number applied; sending the whole batch again applies those a second time. On an anchor failure the body can also carry nearestMatchOffset and nearestMatchSnippet; they appear only when the anchor matches the document except for whitespace (usually a different newline count), so their absence means the text is not in the document. Anchor matching is exact. LINE BREAKS: each "\n" is a paragraph break, except inside a code block (an insert strictly inside one, or a replace within one, stays in it; at its very start / end a "\n" is a paragraph break). A delete or replace across one JOINS the paragraphs (the first keeps its formatting, except that a range starting at a line start keeps the later line's paragraph); a replace with as many lines as it spans rewrites each line in place, and deleting a whole line with its "\n" joins nothing; identical whole lines at the start / end of find and replace are left out ("2\naf" → "2\nA\nB\naf" only inserts "A\nB\n"). After a join the document can differ from what a position computed before it assumed: list items after a plain paragraph can't join it (one "\n" stays), and a code block's lines joined into a paragraph become hard breaks the plain text doesn't show. While someone has the document open, a patch that would join paragraphs is refused as a whole (409 join_blocked_live_editors, nothing applied); edits within a line and rewrites of whole lines are not affected.

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": {
      "id": "<id>",
      "operations": "<operations>"
    },
    "name": "patch-document"
  }
}

Input Schema

NameRequiredDescriptionDefault
idYesDocument ID
authorNoName shown on your edits and comments (e.g. "MyAgent"), with a robot mark as an agent. Invisible and text-direction characters are removed, line breaks and control characters become spaces, and it is cut to 256 characters. A name that resembles ODocs.co or Octaria (including look-alike spellings) is shown as "Agent (Anonymous)". When any of that happens the result has a `warning` field saying what changed.
operationsYesOperations, applied in order. Text-anchored ops (insert-after / insert-before / replace-text / delete-text) name exact text that the server resolves to a position; position-based ops (insert / delete / replace) take character offsets.
expectedVersionNoThe document version from your last read. If the document has changed since, the patch is refused with 409 and nothing is applied (conflict detection).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / author / description
      Previous value: -"Name shown on your edits and comments (e.g. \"Claude via Greg\"), with a robot mark as an agent. Invisible and text-direction characters are removed, line breaks and control characters become spaces, and it is cut to 256 characters. A name that resembles ODocs.co or Octaria (including look-alike spellings) is shown as \"Agent (Anonymous)\". When any of that happens the result has a `warning` field saying what changed."New value: +"Name shown on your edits and comments (e.g. \"MyAgent\"), with a robot mark as an agent. Invisible and text-direction characters are removed, line breaks and control characters become spaces, and it is cut to 256 characters. A name that resembles ODocs.co or Octaria (including look-alike spellings) is shown as \"Agent (Anonymous)\". When any of that happens the result has a `warning` field saying what changed."
  2. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Exceptional disclosure well beyond the annotations: non-atomic application, no rollback, appliedOps:N on failure, re-sending reapplies prior ops, 409 conflict and join_blocked_live_editors codes, and real-time visibility to open editors. The destructiveHint annotation is consistent with this. The one gap is that the lengthy line-break/join treatise is more engine spec than behavior needed at call time, so it earns a 4 rather than a 5.

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

Conciseness3/5

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

Front-loaded and logically ordered, but massively over-sized: the LINE BREAKS exposition, whole-line trimming rules, and code-block join caveats read as engine documentation and bury the practical call guidance. Significant trimming is warranted.

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?

No output schema exists, but the description covers the return shape ({ id, version, ok } plus warning) and error bodies. Combined with full schema coverage and detailed mutation semantics, an agent has everything needed to call it correctly. The 4 reflects that the join/line-break behavior is stated as a rule set rather than as a decision the caller can act on.

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 meaningfully reframes the 'operations' parameter by splitting text-anchored (exact text, no offsets, occurrence for duplicates) from position-based ops, and explains how '\n' and joins reinterpret offsets. It also reinforces expectedVersion semantics already in 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 specific verb plus resource and scope: 'Applies one or more edit operations, in order, to an existing ODocs.co document.' The word 'existing' plus the mutation framing cleanly separates it from create-document and get-document without needing their schemas.

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

Usage Guidelines4/5

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

Gives clear conditions for using the tool: edits to an existing document, expectedVersion for conflict detection, and the live-editor join restriction that forces a different approach. It stops short of explicitly naming a sibling (e.g., get-document first to obtain a version), so it is not a full when/when-not/alternative map.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources