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.
file_path
string
Path to the DOCX file. Provide either file_path or google_doc_id.
google_doc_id
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
target_paragraph_id
string
required
The _bk_* paragraph ID returned by read_file or grep.
old_string
string
required
The exact text to find within the target paragraph.
new_string
string
required
The replacement text.
instruction
string
required
A plain-language description of the change. Stored in the edit history for auditing.
normalize_first
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.
file_path
string
Path to the DOCX file. Provide either file_path or google_doc_id.
google_doc_id
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
positional_anchor_node_id
string
required
The _bk_* paragraph ID that determines the insertion position.
new_string
string
required
Text content of the new paragraph.
instruction
string
required
A plain-language description of the change. Stored in the edit history for auditing.
position
string
default:"AFTER"
Where to insert the paragraph relative to the anchor. Either BEFORE or AFTER.
style_source_id
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.
file_path
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.
file_path
string
Path to the DOCX file. Provide either file_path or google_doc_id.
google_doc_id
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
strict
boolean
When true, fails on any layout value that cannot be applied exactly.
paragraph_spacing
object
Configure spacing for one or more paragraphs. All sub-fields are optional.
row_height
object
Configure height for table rows. All sub-fields are optional.
cell_padding
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.
file_path
string
required
Path to the DOCX file.
paragraph_ids
string[]
_bk_* paragraph IDs to target. If omitted, clears formatting from all paragraphs.
clear_highlight
boolean
Remove highlight formatting.
clear_bold
boolean
Remove bold formatting.
clear_italic
boolean
Remove italic formatting.
clear_underline
boolean
Remove underline formatting.
clear_color
boolean
Remove font color.
clear_font
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.
file_path
string
Path to the DOCX file. Provide either file_path or google_doc_id.
google_doc_id
string
Google Doc ID or URL. Extract the ID from the URL: docs.google.com/document/d/{ID}/edit.
save_to_local_path
string
required
Destination path for the saved file.
clean_bookmarks
boolean
Strip internal _bk_* bookmark annotations from the saved output.
save_format
string
default:"clean"
What to save. One of clean (no revision markup), tracked (all edits as tracked changes), or both (saves two files).
allow_overwrite
boolean
When true, overwrites an existing file at save_to_local_path. Defaults to false.
tracked_save_to_local_path
string
Destination path for the tracked-changes output when save_format is both.
tracked_changes_author
string
Author name attributed to tracked changes in the output.
tracked_changes_engine
string
Comparison engine used to generate tracked changes. One of auto or atomizer.
fail_on_rebuild_fallback
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.

Build docs developers (and LLMs) love