Skip to main content
Glama

Edit a file

edit_file

Applies 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

NameRequiredDescriptionDefault
pathYesPath of the doc to edit, e.g. "main.tex"
editsYesApplied in order, each to the result of the previous one
dryRunNoShow the diff without changing anything
projectNoProject name, id or Overleaf URL. May be omitted when exactly one project is pinned.
suggestNoRecord as tracked changes (suggestions) instead of direct edits

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.1.4
    • addedInput schema / properties / edits / items / properties / replaceAll / description
      Added value: +"Replace every occurrence of oldText instead of requiring exactly one (default false)"
    • addedInput schema / properties / path / description
      Added value: +"Path of the doc to edit, e.g. \"main.tex\""
  2. First observedv2.1.1

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only declare openWorldHint and destructiveHint=false; the description adds substantial behavioral context beyond them: edits land live with concurrent typing merged rather than overwritten, all edits are applied atomically or not at all, and each edit is recorded in project history. It also explains the side effect of suggest=true (tracked changes the author can accept or reject), which no annotation conveys.

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?

Four sentences, each front-loaded with the highest-value fact first: what it does, then collaboration/atomicity semantics, then suggest mode, then the sibling routing rule. No filler or restatement of the title.

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 write tool with no output schema this covers the important ground: atomicity, live-collaboration behavior, history recording, and tracked-change mode. It omits failure semantics (e.g. what happens when oldText is not unique or a match is missing) and does not mention dryRun as a safe preview, which would round it out.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already carries path, edits, replaceAll, dryRun and suggest. The description adds meaning mainly for suggest (tracked changes accept/reject in the review panel) and reinforces atomicity across the edits array, but says nothing about dryRun or project resolution, which the schema already handles. Baseline 3 is appropriate.

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?

States a specific verb and resource ('Applies exact search-and-replace edits to a file') and explicitly names the sibling it is not ('write_file replaces a whole file'). An agent can distinguish edit_file from write_file without opening either schema.

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

Usage Guidelines5/5

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

Gives an explicit selection rule ('Use it for targeted changes; write_file replaces a whole file') and a second routing rule for suggest=true (tracked changes reviewed in Overleaf's panel). The alternative and the condition that selects it are both named.

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