Edit a file
edit_fileReplace an exact string in an Overleaf project file and save changes via Git or web mode. Requires a unique match unless replace_all is set.
Instructions
Replace an exact string in a project file and save it to Overleaf. old_string must match exactly once unless replace_all is set. Uses Git; falls back to the opt-in web mode if enabled.
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>",
"old_string": "<old_string>",
"new_string": "<new_string>"
},
"name": "edit_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path relative to the project root. | |
| project | No | Project ID or Overleaf project URL (or project name in web mode). Defaults to OVERLEAF_PROJECT_ID. | |
| new_string | Yes | Replacement text. | |
| old_string | Yes | Exact text to replace, including whitespace. | |
| replace_all | No | Replace every occurrence instead of requiring a unique match. | |
| commit_message | No |