Docs Replace Document Text
docs_replace_document_textReplace every occurrence of specified text in a Google Docs document using its document ID; optionally match case and return the number of occurrences changed.
Instructions
Replace every occurrence of a piece of text in a Google Docs document. The document_id comes from drive_list_files, search_workspace or docs_create_document; to add text use docs_append_document_text, and for formatting or targeted edits use docs_batch_update_document (extended tool tier). Returns status 'ok', document_id, revision_id and occurrences_changed, which is 0 when nothing matched.
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": {
"contains_text": "<contains_text>",
"document_id": "<document_id>",
"replace_text": "<replace_text>"
},
"name": "docs_replace_document_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| match_case | No | Match letter case exactly when true; by default matching ignores case. | |
| document_id | Yes | Google Docs document ID: the Drive file ID, also the long ID in the document's URL. | |
| replace_text | Yes | Text that replaces each occurrence; an empty string deletes the matches. | |
| contains_text | Yes | Exact text to find; every occurrence is replaced. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Machine-readable operation status. | |
| document_id | No | ||
| revision_id | No | ||
| occurrences_changed | No |