Edit a file
edit_fileReplace an exact text occurrence with new content, view the resulting diff, and keep a backup for undo.
Instructions
Replaces an exact occurrence of old_string with new_string and shows a diff. If old_string occurs more than once, set replace_all=true explicitly. A backup is saved before editing (undo_last_change).
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 | File path | |
| new_string | Yes | Replacement text (may be empty to delete the fragment) | |
| old_string | Yes | Text to find | |
| replace_all | No | Replace all occurrences instead of only the unique one |