Skip to content

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.

Capabilityworkspace.replace_text_in_file
AreaWorkspace and files
Accesschanges files
Reaches—
Rightswrite
Dry rundry_run, on unless the call turns it off

Arguments

ArgumentTypeDescription
pathrequiredstringWorkspace-relative text file.
old_textrequiredstringThe text to replace (not empty).
new_textrequiredstringWhat it becomes.
replace_allbooleanReplace every occurrence (default false: the text must occur exactly once).
case_sensitivebooleanMatch case (default true).
dry_runbooleanOnly 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.

Terminal window
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"
]
}
}
}