Skip to main content
Glama

findAndReplace

Replace all visible text matches in a Google Docs document or tab and return the replacement count; an empty replacement deletes matches. Hyperlink targets cannot be changed.

Instructions

Replaces all occurrences of a text string throughout the document (or a specific tab). Returns the number of replacements made. Use an empty replaceText to delete all matches. This only changes VISIBLE text — it cannot change a hyperlink target. Renaming a mismatched link (e.g. readDocument flagged a LINK MISMATCH) with findAndReplace reports success but leaves the wrong URL/mailto in place; use modifyText with style.linkUrl on that range instead.

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>",
      "findText": "<findText>",
      "replaceText": "<replaceText>"
    },
    "name": "findAndReplace"
  }
}

Input Schema

NameRequiredDescriptionDefault
tabIdNoScope replacement to a specific tab. If omitted, replaces across all tabs.
findTextYesThe text to search for in the document.
matchCaseNoWhether the search should be case-sensitive. Defaults to false.
documentIdYesThe document ID — the long string between /d/ and /edit in a Google Docs URL.
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.
replaceTextYesThe replacement text. Use an empty string to delete all occurrences.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv4.0.0-rc.1

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the burden well: it discloses the replacement count return, the empty-string deletion idiom, the visible-text-only restriction, and the silent-failure trap where a link rename reports success. It stops short of stating permission or revision requirements, but the duplication caveat is unusually strong for an unannotated write tool.

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 operation and return value, then the visible-text caveat, then the workaround. The final sentence is long and references readDocument output, but every sentence carries real information; nothing is padded.

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, and the description supplies the return value. It covers the main behavioral pitfalls for a six-parameter write tool. Minor gaps: mutation preconditions (readHandle authorization over HTTP) are left entirely to the schema.

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; the description adds a little meaning by pairing document-level versus tab-scoped behavior with the replacement operation, though the empty-string deletion hint largely restates the replaceText schema description.

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 ('replaces all occurrences of a text string throughout the document (or a specific tab)') and immediately contrasts its scope with modifyText for the link-target case, so an agent can separate the two without opening schemas.

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 an explicit when-to-use (bulk string replacement, including deletion via empty replacement) and an explicit when-not with the alternative: link targets need modifyText with style.linkUrl on that range, because findAndReplace reports false success there.

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