Skip to main content
Glama

Search and Replace

search_and_replace
Destructive

Batch find and replace text in Word documents, with dry-run preview, scope selection, and a match limit that aborts before over-replacing.

Instructions

Batch find/replace, safe across Word's fragmented runs. Each item: {find, replace, regex?}; scope: body | footnotes | headers | all. preview=true dry-runs the same engine without touching the file: per-item counts, each match with paragraph index and before/after context, the grand total, and the refusals a real run would hit; review, then rerun with max_replacements set to the previewed total so drift aborts instead of over-replacing. find_formatting={bold, italic, font, size_pt, color, highlight, style, ...} restricts replacement to text carrying that effective formatting (file mode only, no regex; an item without find replaces each entire matching stretch, and the replacement keeps the matched formatting). max_replacements aborts, changing nothing, when total matches would exceed it. track records each replacement as a tracked change by author. Sibling: set_paragraph_text rewrites one whole paragraph when a find string would be unwieldy. Live edits appear immediately as one Ctrl+Z step, unsaved until the user saves; the live result adds live:true and skip counters, and literal finds beyond Word's ~255-char limit are handled automatically. Auto-backup in file mode (backup=False skips rotation); atomic validated save. Documents open in Word edit live, serialized; tracked replaces never re-match their own markup. For anchor-scoped edits, use apply_edits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
liveNoauto: file or live; force: live; off: refuseauto
scopeNobody
trackNo
authorNoClaude
backupNo
previewNo
file_pathYes
replacementsYes
find_formattingNo
max_replacementsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.2.1
    • addedInput schema / properties / live / description
      Added value: +"auto: file or live; force: live; off: refuse"
    • addedInput schema / properties / live / enum
      Added value: +[
      +  "auto",
      +  "force",
      +  "off"
      +]
  2. Changed2 schema fields changedv2.0.0
    • addedInput schema / properties / find_formatting
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedInput schema / properties / preview
      Added value: +{
      +  "default": false,
      +  "type": "boolean"
      +}
  3. Changed1 schema field changedv1.6.1
    • addedInput schema / properties / live
      Added value: +{
      +  "default": "auto",
      +  "type": "string"
      +}
  4. First observedv1.2.1

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only state readOnlyHint=false and destructiveHint=true, but the description discloses substantial behavioral detail: preview mode performs a dry-run 'without touching the file'; max_replacements 'aborts, changing nothing'; tracked changes record by author; auto-backup and atomic save are described; 'Live edits appear immediately as one Ctrl+Z step, unsaved until the user saves.' It also notes that 'tracked replaces never re-match their own markup.' This far exceeds what annotations provide, making the tool's side effects and safety behavior fully transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but not bloated. It starts with purpose, then systematically covers item structure, scope, preview, formatting, max_replacements, tracking, sibling alternatives, live editing, and backup. Each sentence adds a distinct piece of essential information for a complex tool. While it is longer than typical tool descriptions, the complexity justifies the length; no sentence is filler. It is front-loaded with core purpose before diving into details, so a slight deduction for verbosity, but structure is logical and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (10 parameters, nested objects, output schema), the description covers all critical aspects: input semantics, safety workflow, error abort conditions, tracking, backup, live editing, and alternatives. It also explains the output behavior via preview counts and match contexts, which complements the existence of an output schema. No essential information for correct invocation is missing. The description is remarkably complete for a tool of this sophistication.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With schema description coverage at only 10%, the description must carry the weight, and it does. It explains the replacements array structure ('{find, replace, regex?}; scope: body | footnotes | headers | all'), preview behavior and return values, max_replacements semantics ('aborts, changing nothing'), find_formatting restrictions and its mode compatibility, track and author usage, and backup=True default with 'backup=False skips rotation.' Even the live parameter is inferred through 'Live edits appear immediately as one Ctrl+Z step' and 'live:true' output references. The description effectively documents every parameter beyond what the sparse schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description leads with 'Batch find/replace, safe across Word's fragmented runs,' a specific verb+resource pairing that immediately establishes the tool's core function. It then details the item structure and scope options, and explicitly distinguishes itself from the sibling set_paragraph_text by saying it rewrites whole paragraphs when a find string is unwieldy. This gives an agent a precise and unambiguous understanding of what the tool does and how it differs from related tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit alternatives and conditions: 'Sibling: set_paragraph_text rewrites one whole paragraph when a find string would be unwieldy' and 'For anchor-scoped edits, use apply_edits.' It also recommends a safe workflow: 'preview=true dry-runs... review, then rerun with max_replacements set to the previewed total.' This goes beyond vague context and tells the agent exactly when to use this tool versus alternatives, and how to use it responsibly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.