Skip to main content
Glama

edit_file

Replace an exact string in a file with a new value, enforcing a single match unless replace_all is set; use dry_run to preview a unified diff without writing.

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.2.1

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare non-readonly, non-destructive, non-idempotent. The description adds real behavioral detail beyond that: the exact-once match precondition that causes failure, the replace_all escape hatch, and that dry_run returns a unified diff without writing. It does not mention what happens if the path is missing or whether files are created.

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?

Two tight sentences, front-loaded with the core action and followed by the critical failure condition and preview mode. Nothing is redundant and nothing is missing that belongs at this level.

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?

Output schema exists, so return-value explanation is not required, and the description still clarifies the dry_run return shape. For a mutation tool with 5 parameters it is nearly complete; only preconditions like path existence and encoding/overwrite behavior are absent.

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 carry the load, and it does: it explains old_string/new_string semantics, the failure rule tied to old_string, the effect of replace_all, and the return/no-write behavior of dry_run. Path handling is the only parameter left unelaborated.

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 ('Replace') plus the exact resource transformation ('old_string with new_string in a file'), which is unambiguous and distinguishable from sibling tools like replace_lines or edit_file_multi by virtue of the string-matching semantics.

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

Usage Guidelines4/5

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

Gives the key usage condition ('Fails unless it matches exactly once') and the alternative path ('or replace_all is true'), plus a preview mode via dry_run. It stops short of explicitly comparing itself to edit_file_multi or replace_lines, so an agent must infer which sibling to pick for multi-edit cases.

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