Replace text in a file
edit_fileReplace an exact string in a UTF-8 text file, requiring a unique match by default and optionally replacing all occurrences; writes changes atomically.
Instructions
Replace an exact string in a UTF-8 text file. By default old_string must occur exactly once; use replace_all to replace every occurrence. The file is written atomically.
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": {
"path": "<path>",
"old_string": "<old_string>",
"new_string": "<new_string>"
},
"name": "edit_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path or path relative to $HOME. | |
| new_string | Yes | Replacement text. | |
| old_string | Yes | Exact text to find. | |
| replace_all | No | Replace all occurrences. Default false. |