edit_document
Compile semantic document edits into correct Google Docs batchUpdate requests by handling UTF-16 arithmetic and cascading index shifts to prevent silent document corruption.
Instructions
Make changes to a Google Doc with correct index arithmetic.
You cannot safely modify a Google Doc by constructing batchUpdate
requests yourself. The API uses UTF-16 code units with cascading index
shifts — insert 10 characters at position 50, and every subsequent
index in your batch is wrong. A single miscalculation silently corrupts
the document with no error message. This tool compiles your semantic
intent into a correct request sequence.
**Recommended flow:** call read_document first, then describe your
changes using heading names or named ranges as addresses.
Valid operation types: insert_text, delete_content, replace_all_text,
replace_section, update_text_style, update_paragraph_style,
create_paragraph_bullets, convert_to_list, insert_table,
insert_table_row, insert_table_column, delete_table_row,
delete_table_column, insert_bullet_list, insert_numbered_list,
insert_page_break, insert_inline_image, create_header, create_footer,
create_footnote, create_named_range, delete_named_range,
replace_named_range_content.
Args:
document_id: The Google Docs document ID.
operations: List of operation dicts. Each has:
- type: one of the operation types listed above
- address: target location ({"heading": "Budget"}, {"start": true}, etc.)
- params: operation-specific parametersInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_id | Yes | ||
| operations | Yes |