Skip to main content
Glama
Google Workspace MCP Server

Google Workspace MCP Server

by mutallipp

Find and Replace Doc

find_and_replace_doc
Destructive

Find and replace text throughout a Google Doc without calculating indices, enabling safe updates to placeholders, phrases, and targeted content.

Instructions

Finds and replaces text throughout a Google Doc. No index calculation required.

This is the safest way to update specific text in a document because it does not require knowing any indices. Use this tool when you need to:

  • Replace placeholder text (e.g., {{TITLE}}) with real content

  • Update specific words or phrases throughout the document

  • Make targeted text changes without risk of index errors

For building documents from scratch, consider inserting text with unique placeholders via batch_update_doc, then using this tool to replace them.

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": {
      "user_google_email": "<user_google_email>",
      "document_id": "<document_id>",
      "find_text": "<find_text>",
      "replace_text": "<replace_text>"
    },
    "name": "find_and_replace_doc"
  }
}

Input Schema

NameRequiredDescriptionDefault
tab_idNoOptional ID of the tab to target
find_textYesText to search for
match_caseNoWhether to match case exactly
write_modeNo"EDIT" (default) applies the replacements directly; "SUGGEST" records them as suggested edits that collaborators can accept or rejectEDIT
document_idYesID of the document to update
replace_textYesText to replace with
user_google_emailYesUser's Google email address

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.8.0

TDQS

A4.1/5.0
Behavior3/5

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

Annotations already disclose destructiveHint=true, openWorldHint=true and non-idempotent behavior, and the description adds that replacement happens 'throughout' the document (all occurrences) and avoids index errors. It does not say that existing text is permanently overwritten with no undo, or that editing via write_mode=SUGGEST differs in risk – a notable omission for a destructive mutation, which is the one piece of behavior annotations cannot fully convey.

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 verb and the key differentiator, then a scannable bullet list of use cases and a concrete workflow tip. The 'no index calculation required' idea is restated in the intro, the bullets, and implicitly again, which is slight redundancy but not bloat.

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 a full output schema, rich annotations, and 100% parameter coverage, the definition only needs to establish purpose, selection guidance, and the placeholder workflow – all of which it does. The remaining gap is risk context (overwriting all matches irreversibly) for a destructive write tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the schema itself explains find_text, replace_text, match_case, write_mode's EDIT/SUGGEST distinction, and tab_id. The description only gestures at placeholder-style find_text and adds nothing about case matching, tab targeting, or suggest-vs-edit semantics, so the baseline of 3 applies.

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 ('Finds and replaces text throughout a Google Doc') and immediately differentiates itself from index-based editing ('No index calculation required'), which separates it from modify_doc_text and insert_doc_elements.

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?

Provides an explicit when-to-use list (placeholder substitution, phrase updates, targeted changes) plus a named alternative with its condition: build documents from scratch with batch_update_doc and placeholders, then run this tool. Both the selection and the routing are stated outright.

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