Replace text in many files
replace_in_filesReplaces every occurrence of a text string or regex across text files, with per-file backups, dry-run preview, and a single undo step. Skips binary files, node_modules, .git, and .mcp by default.
Instructions
Replaces every occurrence of a string (or regular expression) across text files, with a backup of each changed file and a single undo step. Skips binary and very large files, node_modules, .git and .mcp by default. Use dry_run=true to preview the changes first.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>",
"replacement": "<replacement>"
},
"name": "replace_in_files"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Where to search (defaults to root) | . |
| query | Yes | Text or regular expression to find | |
| ignore | No | Additional names/globs to skip | |
| dry_run | No | Only report what would change; do not write files | |
| include | No | File glob, e.g. `*.js` or `src/**/*.ts` | |
| is_regex | No | Treat query as a regular expression | |
| max_files | No | Stop after changing this many files | |
| replacement | Yes | Replacement text (may be empty) | |
| max_file_size | No | Skip files larger than this size (bytes) | |
| case_sensitive | No | Match case |