Skip to main content
Glama

batchModifyText

Apply up to 200 small text edits—replace, insert, delete, or style—to a Google Doc in one atomic batch with conflict checks and optional dry-run preview.

Instructions

Best for MANY small, scattered text edits in one document — the multi-location form of modifyText. Applies up to 200 operations (replace a range or found text, insert at an index, delete, apply text or paragraph styling) in ONE atomic batchUpdate. Every target is resolved against one document snapshot and applied highest-index-first, so the indices you read stay valid for all of them and you do not have to recompute offsets between edits. All-or-nothing: if one operation is invalid, none are applied, and the whole batch is guarded by a single revision check, so a concurrent edit is reported as a conflict rather than written against shifted indices. If the document changed after you read it, every operation is classified against that change: textToFind operations are re-resolved against the current document and proceed when the change did not touch them, while explicit index operations are refused unless the change landed strictly after their range. Any operation that is refused refuses the whole batch, naming what changed and where. Operations whose resolved ranges overlap are rejected up front, naming both. Pass dryRun to get the proposed-vs-current unified diff, an explicit deletion summary, and a per-operation breakdown without writing; a real call returns the same diff for what it applied. This tool is TEXT-ONLY, like modifyText: a multi-line replacement is inserted as one blob with a single paragraph style, so markdown syntax stays literal and list nesting is flattened. For structured content (lists, headings, tables) at a range use replaceRangeWithMarkdown; to rewrite a whole document use replaceDocumentWithMarkdown — but prefer this tool over that one for local edits, because a full-body rewrite orphans comment anchors and regenerates every headingId. Use readDocument with format='index' for indices, or listHeadings for the outline. Newly inserted text carries the document's default text color explicitly, when the document defines one.

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": {
      "documentId": "<documentId>",
      "operations": "<operations>"
    },
    "name": "batchModifyText"
  }
}

Input Schema

NameRequiredDescriptionDefault
tabIdNoThe ID of the specific tab to operate on. Applies to every operation in the batch. If not specified, operates on the first tab.
dryRunNoResolve and validate every operation, return the unified diff and the per-operation summary, and make no writes at all.
documentIdYesThe document ID — the long string between /d/ and /edit in a Google Docs URL.
operationsYesThe edits to apply, 1-200. Order does not matter: targets are resolved against one snapshot and applied highest-index-first, so the indices you read stay valid for every operation.
readHandleNoCapability returned by a previous readDocument call for this document (and tab). Required over HTTP on the 2026-07-28 runtime: it authorizes the write and pins it to the revision that read saw. Omit it on stdio to use that connection's most recent read.
expectedRevisionIdNoOptional compare-and-write assertion: the write is refused unless the read handle was issued for this revision. It is an assertion only, never authorization.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv4.0.0-rc.1

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: all-or-nothing atomicity, highest-index-first resolution so indices stay valid, a single revision guard, and detailed conflict semantics (textToFind re-resolved, index ops refused unless the change landed after their range, refusal names what changed). It also discloses overlap rejection, dryRun vs real-call return behavior, the text-only blob insertion limitation, and that full-body rewrites orphan comment anchors and regenerate headingIds.

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?

Front-loaded with the one-line selection rule, then layered detail in a logical order. It is dense and long, with some repetition of the snapshot/index-validity point across sentences, but nearly every sentence carries non-obvious behavioral information.

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

Completeness5/5

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

For a complex mutation tool with 6 parameters, nested operation objects, no annotations, and no output schema, the description covers atomicity, conflict handling, overlap rejection, return shape of previews, and content limitations — everything an agent needs to call it correctly and interpret the result.

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 the baseline is 3; the description adds genuine meaning beyond the schema by explaining that operation order does not matter, that targets are resolved against one snapshot, and how dryRun's output differs from a real call. It does not explain readHandle vs expectedRevisionId semantics at the parameter level, leaving that to 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 precise verb and resource — applying up to 200 edit operations in one atomic batchUpdate against a single document snapshot — and immediately positions itself as 'the multi-location form of modifyText'. It names the sibling it is not for structured content (replaceRangeWithMarkdown) and whole-document rewrites (replaceDocumentWithMarkdown).

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?

Explicit routing: 'Best for MANY small, scattered text edits', use replaceRangeWithMarkdown for structured content at a range, replaceDocumentWithMarkdown for full rewrites but 'prefer this tool over that one for local edits'. It also says where to get index input (readDocument with format='index', listHeadings) and when to reach for dryRun.

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

Deploy Server

Other Tools