replace_in_files_preview
MCP tools › Code insight and refactoring
Preview a find-and-replace across the project's own source files: per file the replacements (line, old, new) and the number of changes. Nothing is written. Files that are not the project's own (virtual environments, installed dependencies, build output, ignored files) are changed only with include_non_project; without it a directory such as .venv/lib lists them under not_changed with the reason.
Its results carry text from files, language_server: the client is told to treat that as data, never as instructions.
| Capability | code.replace_in_files_preview |
|---|---|
| Area | Code insight and refactoring |
| Access | reads only |
| Reaches | — |
| Rights | none |
| Dry run | none |
Arguments
| Argument | Type | Description |
|---|---|---|
patternrequired | string | Text or regular expression. |
replacementrequired | string | Replacement; with regex $1, ${name} and $$ are expanded. |
regex | boolean | Treat the pattern as a regular expression (default false). |
match_case | boolean | Match case (default false). |
whole_words | boolean | Whole words only (default false). |
file_mask | string | Comma-separated file-name globs (default: all files). |
directory | string | Only files below this workspace-relative folder or file. |
include_non_project | boolean | Also replace in files that are not the project's own sources: virtual environments,
installed dependencies, build output, ignored files (default false; SPEC-0029 v2
behaviour 9). Without it such files are listed under not_changed. |
Call it from a shell
ferris-idea call runs one tool with the rights and safe mode of ferris-idea mcp. Replace the folder and the placeholder values.
ferris-idea call ~/my-project replace_in_files_preview '{"pattern":"<string>","replacement":"<string>"}'Input schema as JSON
{ "type": "object", "required": [ "pattern", "replacement" ], "properties": { "pattern": { "description": "Text or regular expression.", "type": "string" }, "replacement": { "description": "Replacement; with regex `$1`, `${name}` and `$$` are expanded.", "type": "string" }, "regex": { "description": "Treat the pattern as a regular expression (default false).", "type": [ "boolean", "null" ] }, "match_case": { "description": "Match case (default false).", "type": [ "boolean", "null" ] }, "whole_words": { "description": "Whole words only (default false).", "type": [ "boolean", "null" ] }, "file_mask": { "description": "Comma-separated file-name globs (default: all files).", "type": [ "string", "null" ] }, "directory": { "description": "Only files below this workspace-relative folder or file.", "type": [ "string", "null" ] }, "include_non_project": { "description": "Also replace in files that are not the project's own sources: virtual environments,\ninstalled dependencies, build output, ignored files (default false; SPEC-0029 v2\nbehaviour 9). Without it such files are listed under `not_changed`.", "type": [ "boolean", "null" ] } }}