Skip to main content
Glama

edit

Replace text in files with smart indentation and encoding detection. Preview changes with dry-run before saving.

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.). Reads .editorconfig for indentation settings. Use dry_run=true to preview changes without modifying the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathNoAbsolute path to the file to edit
pathNoAlias for file_path
old_stringNoExact text to find in the file
new_stringNoReplacement text (must differ from old_string)
old_contentNoAlias for old_string
new_contentNoAlias for new_string
replace_allNoReplace all occurrences instead of just the first: true or false. Default: false
dry_runNoPreview changes without modifying the file: 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).
Behavior4/5

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

No annotations are provided, so the description carries full burden. It discloses smart indentation, encoding awareness, .editorconfig support, and dry_run preview. However, it does not mention error behavior (e.g., if old_string not found) or side effects like file permission changes.

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 only five sentences, with the first sentence immediately stating the core purpose. Every sentence adds value (features, usage tip) without redundancy or fluff.

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?

Given no output schema and no annotations, the description covers key behavioral aspects (indentation, encoding, preview) and parameter usage. It lacks details on error handling or post-edit verification, but for a simple replacement tool it is adequately 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 description coverage is 100%, and the description adds context beyond the schema by explaining features like smart indentation, encoding awareness, and dry_run usage. It does not merely repeat the schema but provides meaningful additional information.

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?

The description clearly states the verb ('replaces') and resource ('file'), specifying the action of replacing old_string with new_string. This is distinct from sibling tools like 'write', 'multiedit', and 'regexreplace'.

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 provides some usage tips (e.g., dry_run for preview, smart indentation) but does not explicitly state when to use this tool over alternatives like 'multiedit' or 'regexreplace'. No exclusions or conditional guidance are given.

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

Install Server

Other Tools

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