Edit a file
edit_fileApplies exact search-and-replace edits to an Overleaf file, live and atomically, optionally as tracked changes. Use for targeted changes; write_file replaces a whole file.
Instructions
Applies exact search-and-replace edits to a file, live: collaborators see the change instantly and concurrent typing is merged, not overwritten. All edits apply together or not at all, and Overleaf records them in the project history. With suggest=true the edits become tracked changes the author can accept or reject in Overleaf's review panel. Use it for targeted changes; write_file replaces a whole file.
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 | Path of the doc to edit, e.g. "main.tex" | |
| edits | Yes | Applied in order, each to the result of the previous one | |
| dryRun | No | Show the diff without changing anything | |
| project | No | Project name, id or Overleaf URL. May be omitted when exactly one project is pinned. | |
| suggest | No | Record as tracked changes (suggestions) instead of direct edits |