Skip to main content
Glama

edit

Replace exact text in files using find/replace, scoped, or line-range modes. Returns diff and updates cache.

Instructions

Edit one file by exact text replacement.

Three modes:

  • find/replace: old_string + new_string (the default).

  • scoped: add start_line/end_line to confine the search to a range.

  • line-range: omit old_string and give both lines to replace them wholesale.

old_string must match exactly — whitespace and indentation included — and, unless replace_all=true, must be unique, or the edit fails. Use edit_preview first if you're unsure an anchor is unique. Returns the replacement count, affected line numbers, and a unified diff, and refreshes the cache. For several edits to one file use batch_edit; for a full rewrite use write.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to modify (absolute, or relative to root).
dry_runNoPreview without writing.
end_lineNo1-based inclusive end line for a scoped or line-range edit.
show_diffNoReturn the diff even on a deterministic edit.
new_stringNoReplacement text (an empty string deletes the match).
old_stringNoExact text to find. Omit only for a line-range replacement.
start_lineNo1-based inclusive start line for a scoped or line-range edit.
auto_formatNoRun the formatter after editing.
replace_allNoReplace every occurrence instead of requiring a unique match.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffNo
pathNo
paramsNo
statusNo
replacedNo
truncatedNo
diff_stateNo
diff_statsNo
from_cacheNo
content_hashNo
diff_omittedNo
line_numbersNo
tokens_savedNo
Behavior5/5

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

With no annotations, the description fully discloses behavioral traits: exact match requirement, uniqueness unless replace_all=true, return value (count, line numbers, diff), and cache refresh. No contradictions.

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?

Well-structured with clear sections, front-loaded purpose, and no wasted words. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 9 parameters and multiple modes, the description fully covers purpose, usage, parameter interactions, and return value. Adequate given output schema exists.

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% (baseline 3), but the description adds meaning beyond schema by explaining interaction of parameters in three modes and behavior of replace_all and empty new_string.

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 it edits one file by exact text replacement, and explicitly distinguishes from siblings like batch_edit (for multiple edits) and write (for full rewrite).

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

Usage Guidelines5/5

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

Provides explicit when-to-use guidance for three modes, recommends using edit_preview for uniqueness checking, and names batch_edit and write as alternatives for different needs.

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/CoderDayton/semantic-cache-mcp'

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