Edit File
edit_fileApply ordered line-based text replacements within allowed directories, preview results as a git-style diff, and write nothing if any match fails.
Instructions
Make line-based edits to a text file. Edits apply in order, each to the result of the ones before it, and each replaces the first match of its oldText with newText. oldText must match the file's text exactly, except that line endings (LF or CRLF) never matter and, when there is no exact match, a run of whole lines matches if each line is equal once leading and trailing whitespace is ignored (newText then takes the file's indentation). Whitespace inside a line must match. If any edit has no match, nothing is written and the error shows the closest lines of the file, numbered, to copy oldText from. Returns a git-style diff showing the changes made. Only works within allowed directories.
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>",
"edits": "<edits>"
},
"name": "edit_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The text file to edit. Absolute, or relative to an allowed directory; it must resolve inside the allowed directories. | |
| edits | Yes | The replacements to make, applied in order, each to the result of the ones before it. If any one has no match, none is written. | |
| dryRun | No | Preview changes using git-style diff format |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes |