Skip to main content
Glama

Edit File

edit_file

Replace target strings in a file with occurrence limits and a diff preview to verify changes before saving.

Instructions

Replace target string with replacement text in a file with occurrence control and diff preview.

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

NameRequiredDescriptionDefault
pathYesRelative or absolute path to the file.
countNoNumber of occurrences to replace (0 = replace all, 1 = first only).
new_stringYesThe replacement string.
old_stringYesThe exact string to find (case-sensitive, whitespace-sensitive).

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.1.0
    • addedInput schema / properties / count
      Added value: +{
      +  "default": 0,
      +  "description": "Number of occurrences to replace (0 = replace all, 1 = first only).",
      +  "type": "integer"
      +}
  2. First observedv2.0.0

TDQS

B3.2/5.0
Behavior3/5

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

With no annotations supplied, the description carries full behavioral burden; it does add useful traits — occurrence control and a diff preview — that the schema does not convey. However, it omits whether the diff is preview-only or applied, what happens when old_string is absent or ambiguous, and whether edits are reversible.

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?

A single front-loaded sentence that states the operation and its two notable traits with no filler. It is appropriately tight, though "diff preview" is left unexplained and slightly ambiguous.

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

Completeness3/5

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

An output schema exists, so return values need not be described, and the parameters are fully covered. But for a mutation tool with zero annotations, the definition should say more about failure modes (string not found, multiple matches), permissions, and whether the preview is a dry run.

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 all four parameters are already documented, setting the baseline at 3. The description's mention of "occurrence control" and "diff preview" loosely reinforces the count and new_string semantics but adds no format or behavior detail beyond the schema.

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?

The description gives a specific verb and resource ("Replace target string with replacement text in a file") and signals the differentiators — occurrence control and diff preview — which lets an agent separate it from write_file and batch_replace. It stops short of naming those siblings explicitly.

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

Usage Guidelines2/5

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

There is no statement of when to use this versus alternatives such as write_file, batch_replace, or read_file, and no prerequisites are given. Usage must be inferred entirely from the name and the mention of string replacement.

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