Skip to main content
Glama

edit_file

Replace an exact string in a file, preview changes as a unified diff, and optionally replace all matches; writes fail unless the match is unique.

Instructions

Replace old_string with new_string in a file. Fails unless it matches exactly once (or replace_all is true). dry_run=true returns a unified diff without writing.

Input Schema

NameRequiredDescriptionDefault
pathYes
dry_runNo
new_stringYes
old_stringYes
replace_allNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/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 disclose the two traits that matter most for a mutation tool: the exact-single-match failure mode and that dry_run returns a unified diff without writing. It omits whether the file must already exist, atomicity of the write, and encoding handling.

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?

Three short sentences, zero filler, with the core operation first, the failure condition second, and the safe-preview option last. Every sentence carries distinct information.

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?

An output schema exists so return values need not be described, and the description covers the failure mode plus the dry-run preview — the two things an agent most needs before mutating a file. Missing only secondary details like whether the target file must exist and whether edits are atomic.

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 must compensate; it explains old_string/new_string by naming them, defines replace_all's effect via the uniqueness clause, and spells out dry_run's return behavior. Only 'path' is left unstated (though implied by 'in a file'), and matching semantics such as whitespace/escaping sensitivity are not addressed.

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+resource: replace old_string with new_string in a file. That distinguishes it in spirit from edit_file_multi (multi-edit) and replace_lines (line-based), but no sibling is named explicitly, so the agent must infer the boundary itself.

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?

Gives an actionable precondition ('fails unless it matches exactly once') and the escape hatch ('replace_all is true'), which is effectively guidance on when this call will succeed. It never says when to prefer replace_lines or edit_file_multi instead, so the alternative-selection guidance is only implied.

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