Skip to main content
Glama

Edit a .tex doc in the open Overleaf project

edit_file

Edits 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

TableJSON Schema
NameRequiredDescriptionDefault
pathNoProject-relative path of the doc to edit, e.g. 'main.tex' or 'chapters/intro.tex'. If omitted, defaults to the project's root doc.
trackNoTracked-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_contentYesDesired full content of the file. The server computes a diff against the current content and submits the minimal OT operation.
strict_versionNoIf 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_versionNoOptional safety check. If provided and the doc's current version differs, the edit is rejected.
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the transparency burden. It discloses that edits are applied as OT operations in real-time, that tracking is the default, and that only text docs are editable. It does not mention potential server-side overrides of the tracking request or stale-version races, though these are covered in the schema's parameter descriptions. Overall it provides meaningful behavioral context beyond a simple 'edit' summary.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences, front-loaded with the core action, and every sentence adds information: the mechanism, the default tracking behavior, the path default, and the file-type restriction. No redundant or filler content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema and five parameters, the description covers the core purpose, typical usage, and key constraints. It does not explain the overridable tracking behavior or version-check parameters, but those are thoroughly described in the schema, so the description is sufficient to give the agent a solid mental model. The lack of authentication/permission details is acceptable as it is likely handled at a higher level.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds value by clarifying the path default and the track behavior ('By default appears as a pending suggestion... pass track:'off' to write directly') and by stating the file-type restriction, which is not in the schema. However, it does not elaborate on strict_version or expected_version, which are already well-documented in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Replaces the contents of a doc' via a minimal diff and OT operation over Socket.IO. It distinguishes from siblings by specifying the real-time nature, Review panel behavior, and the restriction to text documents. The purpose is unambiguous and specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear usage context: when to use track:'on' vs 'off', the default path behavior, and that binary files are not editable. However, it does not explicitly contrast with the sibling tool find_and_replace, which might be used for targeted substitutions rather than full-content replacement. The parameter descriptions in the schema add further mode guidance (auto/on/off).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/netique/overleaf-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server