Edit a Google Doc in place
update_docEdit a Google Doc by replacing specific text with find/replace pairs (reports match count; zero matches fails visibly) or rewriting the whole body, with a confirmation step for destructive rewrites.
Instructions
EDIT a Google Doc — the correction append_to_doc cannot make, which until now meant a doc could only ever grow and a wrong line stayed in it forever. Two shapes: replacements:[{find, replace}] rewrites specific text wherever it appears (call read_doc first and match the text EXACTLY; matchCase:false ignores case), or rewrite:"…" replaces the ENTIRE body (rewrite:"" empties it). Find/replace runs immediately and REPORTS how many occurrences changed — zero matches is reported as a FAILURE to match, never as a quiet success, because a text edit that silently does nothing is worse than one that visibly fails. A whole-body rewrite is destructive: call it without confirm first to get the character count, then confirm:true + confirmCells. Both are index-free by design — an agent cannot reliably compute Google’s character offsets, and a wrong offset deletes the wrong sentence.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docUrl | No | a Google Docs URL — the id is extracted from it | |
| confirm | No | ||
| rewrite | No | replace the WHOLE body with this text ("" empties the doc) | |
| documentId | No | the document id (from create_doc, or list_drive_files for one the user picked) | |
| confirmCells | No | echo back the character count the unconfirmed call reported (rewrite only) | |
| replacements | No | find/replace pairs, applied in order |