Skip to main content
Glama

edit_file

Replace an exact substring in a local text file while preserving CRLF/LF endings and UTF-8 BOM. Preview changes with dryRun or update every match with replaceAll.

Instructions

Perform an exact substring replacement in a local text file while preserving CRLF/LF line endings and UTF-8 BOM. Supports dryRun and replaceAll.

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": {
      "filePath": "<filePath>",
      "target": "<target>",
      "replacement": "<replacement>"
    },
    "name": "edit_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
dryRunNo
targetYesExact text block to replace
filePathYesAbsolute file path
replaceAllNo
replacementYesReplacement text

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.1/5.0
Behavior3/5

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

With no annotations, the description carries the full burden and does contribute real behavioral detail about encoding and line-ending preservation. However, it omits the failure semantics that matter most for a mutation tool: what happens if target is not found, matches multiple times without replaceAll, or if the file does not exist. It also gives no indication of return value or whether writes are atomic.

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?

Two tight sentences with the core operation front-loaded and no filler. The trailing 'Supports dryRun and replaceAll' is a bare feature list that earns little, but the overall length is well matched to the tool.

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

Completeness2/5

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

A 5-parameter mutating tool with zero annotations and no output schema needs the description to cover permissions, error conditions, and the effect of its two flags; none of that is present. The encoding-preservation note is valuable but insufficient for an agent to call this safely in edge cases.

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

Parameters2/5

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

Schema coverage is 60%, and the two undocumented parameters are exactly dryRun and replaceAll. The description merely says it 'supports' them, which confirms existence but adds no semantics (does dryRun return the diff without writing? does replaceAll change the not-found/multiple-match behavior?). It adds nothing beyond the schema for filePath, target, and replacement either.

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: exact substring replacement in a local text file, plus the notable fidelity guarantees (CRLF/LF and UTF-8 BOM preserved). An agent knows precisely what the operation is, but nothing distinguishes it from siblings like write_file or batch_edit, which are the obvious alternatives for file modification.

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 only implied: 'exact substring replacement' suggests surgical edits to an existing file rather than whole-file rewrites, which implicitly separates it from write_file. There is no explicit when-to-use, no when-not-to-use, and no mention of batch_edit for multi-edit scenarios, leaving the agent to infer routing.

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