replace_text_in_file
MCP tools › Workspace and files
Replace text in a workspace text file as the window shows it, saved or not. old_text must occur exactly once unless replace_all is true; none or several occurrences are an error naming the count and the 1-based lines, and nothing changes. case_sensitive defaults to true. Returns replacements, the 1-based lines of the replaced places and applied. dry_run defaults to true; dry_run=false needs the user-granted write right and writes through the open editor as one undo step, or to the disk when the file is not open.
| Capability | workspace.replace_text_in_file |
|---|---|
| Area | Workspace and files |
| Access | changes files |
| Reaches | — |
| Rights | write |
| Dry run | dry_run, on unless the call turns it off |
Arguments
| Argument | Type | Description |
|---|---|---|
pathrequired | string | Workspace-relative text file. |
old_textrequired | string | The text to replace (not empty). |
new_textrequired | string | What it becomes. |
replace_all | boolean | Replace every occurrence (default false: the text must occur exactly once). |
case_sensitive | boolean | Match case (default true). |
dry_run | boolean | Only report what would change (default true); false writes, which needs the write right. |
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_text_in_file '{"path":"<string>","old_text":"<string>","new_text":"<string>"}'Input schema as JSON
{ "type": "object", "required": [ "path", "old_text", "new_text" ], "properties": { "path": { "description": "Workspace-relative text file.", "type": "string" }, "old_text": { "description": "The text to replace (not empty).", "type": "string" }, "new_text": { "description": "What it becomes.", "type": "string" }, "replace_all": { "description": "Replace every occurrence (default false: the text must occur exactly once).", "type": [ "boolean", "null" ] }, "case_sensitive": { "description": "Match case (default true).", "type": [ "boolean", "null" ] }, "dry_run": { "description": "Only report what would change (default true); false writes, which needs the `write` right.", "type": [ "boolean", "null" ] } }}