replace_texts
Apply one or more find/replace pairs to a .docx file in a single open/save cycle, with optional tracked changes for auditability.
Instructions
Apply one or more find/replace operations in a single open/save cycle. Use a one-element items array for a single substitution; use multiple items to batch many substitutions efficiently. Items are applied sequentially in the given order.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Absolute path to the .docx file | |
| items | Yes | Array of find/replace pairs, applied sequentially in the given order. Under track_changes=false, a later item can match against text produced by an earlier item (e.g. alpha→beta then beta→gamma yields gamma). Under track_changes=true, the engine rejects overlapping items (where item N's search matches item M's replace, M<N) with INVALID_PARAMETER — issue separate replace_texts calls instead. | |
| track_changes | No | Record edits as tracked changes (w:del/w:ins). Default true. | |
| author | No | Author name for tracked changes | Claude |
| allow_untracked_edit | No | Capability flag required to disable tracked changes. When track_changes is false, this must also be true or the call fails with UNTRACKED_EDIT_NOT_ALLOWED. Default false. This is a safety guard against prompt injection or long-context drift in regulated-industry use — silent edits to legal/regulated documents must be opted into with two independent flags. | |
| include_headers_footers | No | Also replace text in headers and footers. Default false. |