Skip to main content

replace_text

Replace text within a paragraph identified by its _bk_* ID, preserving all run-level formatting. Works with DOCX files and Google Docs.
This tool modifies the document in memory. Call save to persist the result to disk.
If a search fails because the target text is fragmented across multiple adjacent runs with identical formatting, set normalize_first: true. This merges those runs before searching, then restores them afterward.
string
Path to the DOCX file. Provide either file_path or google_doc_id.
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
string
required
The _bk_* paragraph ID returned by read_file or grep.
string
required
The exact text to find within the target paragraph.
string
required
The replacement text.
string
required
A plain-language description of the change. Stored in the edit history for auditing.
boolean
Merge format-identical adjacent runs before searching, then restore them. Useful when text is fragmented across runs.

insert_paragraph

Insert a new paragraph immediately before or after an anchor paragraph identified by its _bk_* ID. Works with DOCX files and Google Docs.
This tool modifies the document in memory. Call save to persist the result to disk.
string
Path to the DOCX file. Provide either file_path or google_doc_id.
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
string
required
The _bk_* paragraph ID that determines the insertion position.
string
required
Text content of the new paragraph.
string
required
A plain-language description of the change. Stored in the edit history for auditing.
string
default:"AFTER"
Where to insert the paragraph relative to the anchor. Either BEFORE or AFTER.
string
A _bk_* paragraph ID whose formatting (pPr and template run) the new paragraph should clone, instead of copying from the anchor. Falls back to the anchor with a warning if the ID is not found.

accept_changes

Accept all tracked changes in the document body, producing a clean document with no revision markup. Returns acceptance statistics.
Accepting changes is irreversible within the current session. The original revision markup is discarded.
string
required
Path to the DOCX file.

format_layout

Apply layout controls including paragraph spacing, table row height, and cell padding. Google Docs supports paragraph spacing only.
This tool modifies the document in memory. Call save to persist the result to disk.
string
Path to the DOCX file. Provide either file_path or google_doc_id.
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
boolean
When true, fails on any layout value that cannot be applied exactly.
object
Configure spacing for one or more paragraphs. All sub-fields are optional.
object
Configure height for table rows. All sub-fields are optional.
object
Configure padding for table cells. All sub-fields are optional.

clear_formatting

Clear specific run-level formatting properties from paragraphs. When no paragraph_ids are provided, the operation applies to every paragraph in the document.
Formatting removal cannot be undone within the current session.
string
required
Path to the DOCX file.
string[]
_bk_* paragraph IDs to target. If omitted, clears formatting from all paragraphs.
boolean
Remove highlight formatting.
boolean
Remove bold formatting.
boolean
Remove italic formatting.
boolean
Remove underline formatting.
boolean
Remove font color.
boolean
Remove font family and size.

save

Save the current document state to disk. For DOCX files, you can save a clean version, a tracked-changes version, or both. For Google Docs, the default behavior creates a checkpoint and returns the revisionId; passing a local path exports the document as DOCX.
When allow_overwrite is false (the default), saving to an existing path raises an error. Set allow_overwrite: true to replace the file.
string
Path to the DOCX file. Provide either file_path or google_doc_id.
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
string
required
Destination path for the saved file.
boolean
Strip internal _bk_* bookmark annotations from the saved output.
string
default:"clean"
What to save. One of clean (no revision markup), tracked (all edits as tracked changes), or both (saves two files).
boolean
When true, overwrites an existing file at save_to_local_path. Defaults to false.
string
Destination path for the tracked-changes output when save_format is both.
string
Author name attributed to tracked changes in the output.
string
Comparison engine used to generate tracked changes. One of auto or atomizer.
boolean
When true, returns an error instead of saving if the comparison engine falls back to rebuild mode, which destroys table structure. Defaults to false.