Change part of a code file
edit_fileReplace one exact passage in an existing file without rewriting the full content, preserving all other bytes. Use for targeted edits or deletions where the old text must match once.
Instructions
Replaces ONE passage inside a file that already exists, leaving every other byte alone — the tool to reach for whenever you are modifying rather than creating. write_file takes the FULL content, so using it to change a heading on an 80 KB page means reproducing 80 KB exactly, and one character wrong in that reproduction is a corruption that surfaces when a visitor loads the page, not when the tool returns. oldString must match the file exactly (whitespace included) and appear ONCE — include a line above and below to make it unique, or pass replaceAll. newString may be empty to delete the passage. The read-modify-write happens server-side in one request, so two edits cannot interleave. Nothing is saved if the result would not parse. The reply carries the file's sha256, so you can prove what the server now holds.
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": {
"workspaceId": "<workspaceId>",
"name": "<name>",
"oldString": "<oldString>",
"newString": "<newString>"
},
"name": "edit_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seo | No | How much to report about the HTML pages being written: "full" (default) everything, "minimal" only what an indexed page cannot do without, "none" to say nothing. Never blocks the write; a page with <meta name="robots" content="noindex"> is exempt either way. | |
| name | Yes | Case-sensitive file name, folders with "/" — e.g. "pages/app.css", "lib/http.js". | |
| newString | Yes | What to put in its place. Empty string deletes the passage. | |
| oldString | Yes | The exact text to replace, whitespace included. Must appear exactly once unless replaceAll is true. | |
| replaceAll | No | Replace every occurrence instead of requiring a unique match. | |
| workspaceId | Yes |