edit
Modify Python file text via exact string replacements or full rewrites, with type-checked previews and writes blocked when new errors exceed the limit.
Instructions
Edit text in a Python file, type-checked: edit(file_path="src/app.py", old_string="x = 1", new_string="x = 2").
Use this for changes that are not a whole definition (a few lines, an import, a
module-level statement) or for rewriting a whole file (new_text). To replace,
add or delete a function/method/class by name use edit_symbol.
Give either old_string -> new_string (old_string must match exactly once unless
replace_all=true; the reply gives the matching lines and the replacement count) or the
complete new_text (also creates a new file), never both. Each text is at most 1,000,000
characters. The text must be valid Python; new lines take the file's line endings (CRLF
stays CRLF). Writes when the new errors in the file and in the files that import it
stay within max_new_errors (default 0, null = no limit); otherwise nothing is written
and the result lists the errors plus an id for apply_edit. apply=false always
previews. undo_edit reverts.
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": {
"file_path": "<file_path>"
},
"name": "edit"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apply | No | ||
| new_text | No | ||
| file_path | Yes | ||
| new_string | No | ||
| old_string | No | ||
| replace_all | No | ||
| max_new_errors | No | ||
| include_dependents | No |