Skip to main content
Glama

edit

Replaces exact text in files while preserving original encoding, line endings, and indentation. Supports preview via dry-run and replacing all occurrences for safe, accurate updates.

Instructions

Replaces old_string with new_string in the specified file. Smart indentation: auto-converts between tabs and spaces to match the file's style. Encoding-aware: preserves original file encoding (UTF-8, EUC-KR, Shift-JIS, UTF-8 BOM, etc.). Line-ending aware: matches old_string regardless of CRLF/LF, and inserted lines follow the newline style of the region being edited (mixed-newline files stay intact). Reads .editorconfig for indentation settings. Use dry_run=true to preview changes without modifying the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoAlias for file_path
dry_runNoPreview changes without modifying the file: true or false. Default: false
file_pathNoFile to edit. Relative paths use the configured workspace or MCP client 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 all occurrences instead of just the first: true or false. Default: false
indent_styleNoOverride indentation style. Values: tabs or spaces-N (e.g. spaces-4). Empty = auto-detect (default)
expected_hashNoOptional SHA-256 hash of the file. If provided and mismatched, edit is rejected (optimistic concurrency).

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 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"
  2. Addedv0.8.7
  3. Removed
  4. Changed1 schema field changedv0.7.12
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "result": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "result"
      -  ],
      -  "type": "object"
      -}New value: +null
  5. First observedv0.4.2

TDQS

B3.4/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 behavioral burden, and it delivers: smart indentation conversion, encoding preservation across multiple encodings, CRLF/LF-insensitive matching, newline-style preservation in mixed files, .editorconfig awareness, and a dry-run preview mode. It lacks disclosure of failure/error behavior and return semantics, but the non-obvious mutation-safety traits are well detailed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Six sentences with the core purpose front-loaded and each subsequent sentence earning its place by disclosing a distinct, non-obvious behavior (indentation, encoding, line endings, editorconfig, dry-run). It is longer than average, but nearly every sentence prevents a real-world correctness bug.

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 a 10-parameter tool with no output schema, the description covers behaviors well but leaves gaps: it never states what a successful call returns, what happens when old_string is not found or ambiguous, or how replace_all/expected_hash/indent_style interact behaviorally. Core editing semantics are covered; edge and result semantics are missing.

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 all 10 parameters are already documented (including aliases, replace_all, indent_style, and expected_hash). The description adds no parameter-level meaning beyond what the schema provides; it revisits dry_run but without new information. Baseline 3 applies.

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 first sentence states a specific verb and resource: 'Replaces old_string with new_string in the specified file.' This identifies a targeted in-file substitution and separates it from read/write-style siblings. However, it does not explicitly differentiate itself from the similarly named siblings patch and multiedit, so it stops short of a 5.

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?

The description gives no guidance on when to choose edit over siblings such as patch, multiedit, or write, and no exclusions or alternative conditions. The only usage hint is 'Use dry_run=true to preview changes,' which is a safety option rather than a selection rule.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/knewstimek/agent-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server