replace_in_file
Performs targeted text replacement in remote files without reading entire content. Includes dry-run preview and errors when the exact text isn't found.
Instructions
Replace a specific text passage in a remote file without loading the full content. Preferred over write_file for editing large files. Returns error if old_text not found. Supports dry_run preview.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path | |
| count | No | Max replacements (default: 1, 0 = all) | |
| reason | No | Human-readable explanation of what is being changed and why (for audit log) | |
| server | Yes | Server name | |
| dry_run | No | Preview changes without applying | |
| new_text | Yes | Replacement text | |
| old_text | Yes | Exact text to find (multi-line supported) |