Edit a .tex doc in the open Overleaf project
edit_fileEdits Overleaf documents in real time by computing a minimal diff and sending it as an OT operation, with optional tracked changes for review.
Instructions
Replaces the contents of a doc by computing a minimal diff and submitting it as an OT operation over the live Socket.IO connection. The change lands in the web editor in real time. By default the edit appears as a pending suggestion in the Review panel (track:'on'); pass track:'off' to write directly. If path is omitted, defaults to the project's root doc. Only .tex / .bib / .md / similar text docs are editable — binary files are not.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Project-relative path of the doc to edit, e.g. 'main.tex' or 'chapters/intro.tex'. If omitted, defaults to the project's root doc. | |
| track | No | Tracked-changes mode. This is a client *request*, not a guarantee — when the project has `track_changes_on_for_me: true` (visible in `open_project`'s response), the server forces tracking regardless of what you pass, and the tool response will report `tracked: true, track_overridden: true`. Don't tell the user 'this will be untracked' without first checking that flag from `open_project`. Modes: 'on' (default) — explicitly request tracking; edit lands as a pending suggestion in Overleaf's Review panel, the agent-collaborator-friendly choice. 'off' — request a direct untracked write (may be overridden as above). 'auto' — track iff the project's tc setting says so. | on |
| new_content | Yes | Desired full content of the file. The server computes a diff against the current content and submits the minimal OT operation. | |
| strict_version | No | If true, re-fetch the doc version from the server before sending the edit and refuse if the cached baseline is stale. Catches races from parallel agents (each MCP process has its own cache) or a concurrently open Overleaf web editor at the cost of one extra round-trip. Without this, the server's OT transform handles stale-version edits silently, which can land the op in an unexpected location or collapse it to a no-op. Recommended when several agents may be editing the same project. | |
| expected_version | No | Optional safety check. If provided and the doc's current version differs, the edit is rejected. |