Skip to main content
Glama

replace_in_file

Destructive

Replace one exact occurrence of text in a ShareLaTeX/Overleaf document, with optional SHA-256 stale-content guard; use an empty replacement to delete that occurrence.

Instructions

Replace one exact occurrence of text in a ShareLaTeX document.

This changes the remote project. The MCP client controls user confirmation.
expected_sha256 optionally guards against stale content (UTF-8 SHA-256). project is a project name or id. The file must be
an editable text document, not an uploaded binary. old_text must occur
exactly once. new_text may be empty to delete that occurrence.

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": {
      "project": "<project>",
      "file_path": "<file_path>",
      "old_text": "<old_text>",
      "new_text": "<new_text>"
    },
    "name": "replace_in_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
projectYes
new_textYes
old_textYes
file_pathYes
expected_sha256No

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and idempotentHint=false, so the description doesn't need to re-state danger. It does add genuinely new context: the change hits the remote project, confirmation is delegated to the MCP client, and expected_sha256 guards against stale content. It omits failure behavior when old_text matches zero or multiple times, which is the main remaining gap.

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

Conciseness4/5

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

Front-loaded with the core action, then behavior, then parameter notes — a sensible order with little waste. Minor friction from the hard line break that inserts "The file must be an editable text document" mid-way through the parameter remarks, fragmenting the parameter block.

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?

With an output schema present, return values need not be explained, and the description covers mutation scope, confirmation responsibility, the binary-file restriction, and the stale-guard parameter. What's missing is error semantics on zero or multiple matches and file_path resolution, both of which an agent would want before calling.

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 description coverage is 0%, so the description carries the full burden and largely meets it: project (name or id), old_text (must occur exactly once), new_text (may be empty to delete), and expected_sha256 (optional stale-content guard, UTF-8 SHA-256). Only file_path is left entirely unexplained, e.g. relative-to-project-root semantics.

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

Purpose4/5

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

States a specific verb and resource ("Replace one exact occurrence of text in a ShareLaTeX document") plus a distinguishing constraint: exactly one occurrence, exact match. It does not explicitly differentiate itself from siblings like write_file or append_to_file, so it stops short of 5.

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

Usage Guidelines3/5

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

Usage is implied by the constraints: "The file must be an editable text document, not an uploaded binary" and "old_text must occur exactly once" tell the agent the preconditions for a successful call. However, there is no explicit when-to-use-this-instead-of-append_to_file-or-write_file routing guidance, leaving the choice to inference.

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