Skip to main content
Glama

edit

Replace exact text in files while preserving encoding and line endings, adapting indentation, and optionally previewing dry-run or enforcing hash-guarded 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.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "edit"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoAlias for file_path
dry_runNoPreview only; default false
encodingNoCharset override, e.g. EUC-KR or Shift_JIS; overrides .editorconfig, BOM takes priority
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. Changed1 schema field changedv1.0.5
    • addedInput schema / properties / encoding
      Added value: +{
      +  "description": "Charset override, e.g. EUC-KR or Shift_JIS; overrides .editorconfig, BOM takes priority",
      +  "type": "string"
      +}
  2. 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"
  3. 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"
  4. Addedv0.8.7
  5. Removed
  6. Changed1 schema field changedv0.7.12
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "result": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "result"
      -  ],
      -  "type": "object"
      -}New value: +null
  7. First observedv0.4.2

TDQS

A3.5/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 real work: it discloses encoding preservation, local line-ending preservation, .editorconfig-driven indentation adaptation, a dry-run mode, and hash-guarded edits that reject on mismatch. It still omits failure behavior for missing or ambiguous old_string and whether the file must already exist.

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?

A single front-loaded sentence states the core operation first, then enumerates the behavioral guarantees. No filler, no restatement of the tool name, and every clause maps to a distinct behavior an agent would otherwise have to guess.

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?

For an 11-parameter mutation tool with no annotations and no output schema, the description covers the important behavioral traits but leaves error semantics, uniqueness requirements, and return information unstated. It is adequate but not complete for the complexity involved.

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 coverage is 100%, so the schema already documents all 11 parameters including the aliases and the SHA-256 guard, which sets the baseline at 3. The description adds modest color on expected_hash, encoding precedence, and dry-run, but does not explain the alias pairs or replace_all semantics beyond what the schema states.

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 gives a specific verb and mechanism: "Replace exact text in a file," which is meaningfully narrower than write or patch. It does not name any sibling (multiedit, patch, write) to differentiate itself, so an agent must infer the boundary from "exact text" alone.

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

Usage Guidelines2/5

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

There is no explicit when-to-use or when-not guidance, and no alternative tool is named despite multiedit, patch, and write being obvious overlapping siblings. At best an agent can infer that exact-match replacement applies to an existing file, which is implied rather than stated.

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