Edit a file
files_editChange PART of a file by replacing an exact snippet, leaving the rest untouched. Prefer this over files.write for any edit to an existing file: rewriting a whole file to change a few lines is slow, expensive and loses anything you did not repeat. The snippet must appear EXACTLY once unless you pass replaceAll.
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": {
"id": "<id>",
"path": "<path>",
"oldString": "<oldString>",
"newString": "<newString>"
},
"name": "files_edit"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| path | Yes | REQUIRED. The file to edit, volume-root relative, e.g. '/index.js'. | |
| newString | Yes | What to put in its place. An empty string deletes the snippet. | |
| oldString | Yes | The exact text to replace, copied from the file including its indentation. | |
| replaceAll | No | Replace every occurrence instead of requiring exactly one. |