Skip to main content
Glama

Replace text in a file

edit_file
Destructive

Replace an exact string in a UTF-8 text file, requiring a unique match by default and optionally replacing all occurrences; writes changes atomically.

Instructions

Replace an exact string in a UTF-8 text file. By default old_string must occur exactly once; use replace_all to replace every occurrence. The file is written atomically.

Input Schema

NameRequiredDescriptionDefault
pathYesAbsolute path or path relative to $HOME.
new_stringYesReplacement text.
old_stringYesExact text to find.
replace_allNoReplace all occurrences. Default false.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false and idempotentHint=false, so the safety profile is handled. The description adds non-obvious behavior the annotations do not: exact matching, the single-occurrence default that makes calls fail, and atomic writes. It does not cover file-not-found or permission errors, keeping it at 4.

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, front-loaded with the core operation, followed by the match constraint and the atomicity guarantee. Every sentence carries information an agent needs.

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 four fully documented parameters, annotations and no output schema, the definition covers what to send and the key failure mode (non-unique match). It leaves out edge cases like missing files or encoding problems, so it is not quite complete.

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 coverage is 100%, so the schema already explains each parameter. The description nonetheless adds meaning the schema lacks: the default requires a unique match, and replace_all is the escape hatch for multiple matches. That is real semantic value beyond the field docs.

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 opens with a precise verb+resource ('Replace an exact string in a UTF-8 text file'), which is specific enough to separate it from read_file or delete_path. It stops short of naming write_file, the closest sibling, so an agent must infer that whole-file overwrites belong there.

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?

It gives one real usage rule ('old_string must occur exactly once; use replace_all to replace every occurrence'), which is genuinely helpful. But it never says when to prefer this tool over write_file or how to handle the not-found/ambiguous-match failure case, so tool-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.