Skip to main content
Glama

edit

Replace exact text in files while preserving encoding and line endings, adapting indentation, and offering dry-run and hash verification for safe edits.

Instructions

Replace exact text in a file. Preserves encoding and local line endings, adapts indentation using the file and .editorconfig, and supports dry-run plus hash-guarded edits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoAlias for file_path
dry_runNoPreview only; default false
file_pathNoFile path; relative to workspace/MCP root
new_stringNoReplacement text; must differ from old_string
old_stringNoExact text to find in the file
new_contentNoAlias for new_string
old_contentNoAlias for old_string
replace_allNoReplace every match; default false
indent_styleNotabs or spaces-N; default auto-detect
expected_hashNoExpected SHA-256; mismatch rejects edit

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.9.7
    • changedInput schema / properties / dry_run / description
      Previous value: -"Preview changes without modifying the file: true or false. Default: false"New value: +"Preview only; default false"
    • changedInput schema / properties / expected_hash / description
      Previous value: -"Optional SHA-256 hash of the file. If provided and mismatched, edit is rejected (optimistic concurrency)."New value: +"Expected SHA-256; mismatch rejects edit"
    • changedInput schema / properties / file_path / description
      Previous value: -"File to edit. Relative paths use the configured workspace or MCP client root"New value: +"File path; relative to workspace/MCP root"
    • changedInput schema / properties / indent_style / description
      Previous value: -"Override indentation style. Values: tabs or spaces-N (e.g. spaces-4). Empty = auto-detect (default)"New value: +"tabs or spaces-N; default auto-detect"
    • changedInput schema / properties / new_string / description
      Previous value: -"Replacement text (must differ from old_string)"New value: +"Replacement text; must differ from old_string"
    • changedInput schema / properties / replace_all / description
      Previous value: -"Replace all occurrences instead of just the first: true or false. Default: false"New value: +"Replace every match; default false"
  2. Changed3 schema fields changedv0.9.5
    • addedInput schema / properties / dry_run / type
      Added value: +"boolean"
    • changedInput schema / properties / file_path / description
      Previous value: -"Absolute path to the file to edit"New value: +"File to edit. Relative paths use the configured workspace or MCP client root"
    • addedInput schema / properties / replace_all / type
      Added value: +"boolean"
  3. Addedv0.8.7
  4. Removed
  5. Changed1 schema field changedv0.7.12
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "result": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "result"
      -  ],
      -  "type": "object"
      -}New value: +null
  6. First observedv0.4.2

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations provided, the description carries the full behavioral burden. It discloses several non-obvious traits: preserves encoding and local line endings, adapts indentation via .editorconfig, and supports dry-run and hash-guarded edits. It does not detail failure modes or response format, but for a mutation tool it offers respectable transparency.

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?

The description is a single, tight sentence that front-loads the core action ('Replace exact text in a file') and packs three behavioral notes into a compact clause. Every phrase earns its place with zero fluff.

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?

The tool is moderately complex with 10 parameters, but all are fully documented in the schema. The description covers key behavioral aspects (encoding, line endings, indentation, dry-run, hash). However, it lacks guidance on when to use this tool versus the closely related siblings (write, patch, multiedit), which is a meaningful completeness gap for correct selection.

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 the baseline is 3. The description reiterates the purpose of dry_run and expected_hash and adds context about indentation adaptation, but does not add meaning beyond what the schema already documents for the parameters. It neither compensates for gaps nor contradicts 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 states a specific verb ('Replace'), a resource ('a file'), and a distinctive qualifier ('exact text'), clearly separating it from write (new content) and patch (diff-based). It does not name sibling tools, but the exact-text aspect is sufficiently differentiating against the sibling set.

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?

The description implies usage for exact text replacement and mentions advanced features (dry-run, hash-guard) that suggest safe editing contexts. However, it provides no explicit guidance on when to use this tool versus write, patch, or multiedit, and offers no exclusion criteria or alternative routing.

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