Skip to main content
Glama

edit

Make cache-aware exact replacements in files. Use find/replace or line-range edit to modify specific content while preserving the rest.

Instructions

Edit one file using cache-aware exact replacement.

Prefer this over write when you want to preserve the rest of the file. Use line numbers from read whenever possible to keep the edit precise.

Modes:

  • Find/replace: old_string + new_string

  • Scoped replace: add start_line + end_line

  • Line-range replace: omit old_string, provide start_line + end_line

Routing rules:

  • One localized change: use edit

  • Multiple independent changes in the same file: use batch_edit

  • Full-file rewrite: use write

Precision rules:

  • Keep old_string exact and as short as possible, ideally one line.

  • If a match is ambiguous, add more context or line bounds.

  • Use replace_all=true only when every match should change.

  • Deterministic successful edits omit full diffs unless show_diff=true or debug mode is enabled.

Args: path: File path to modify. old_string: Exact text to find. Omit only for line-range replacement. new_string: Replacement text. replace_all: Replace all matches instead of requiring uniqueness. dry_run: Preview without writing. auto_format: Run formatter after editing. show_diff: Return the diff explicitly for successful deterministic edits. start_line: 1-based inclusive start line for scoped or line-range edit. end_line: 1-based inclusive end line for scoped or line-range edit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
old_stringNo
new_stringNo
replace_allNo
dry_runNo
auto_formatNo
show_diffNo
start_lineNo
end_lineNo

Output Schema

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

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

The description covers cache-aware behavior, deterministic edits, diff suppression, replace_all, dry_run, auto_format, and debug mode. Since no annotations exist, this provides good insight into tool behavior, though it could mention error handling or undo.

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?

Well-structured with clear sections (modes, routing, precision, args). Slightly lengthy but each sentence adds information. Could be tightened slightly, but overall good.

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?

Covers multiple edit modes, routing rules, and precision guidelines. Missing details on output format and error handling, but given the output schema exists and complexity is high, the description is adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All 9 parameters are described in the 'Args' section with context beyond the schema types. Examples include 'old_string: Exact text to find. Omit only for line-range replacement.' This adds significant value as schema coverage is 0%.

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 tool edits one file using cache-aware exact replacement. It distinguishes itself from siblings like batch_edit and write by specifying when each is appropriate.

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?

Explicit routing rules are provided: 'One localized change: use edit; Multiple independent changes: use batch_edit; Full-file rewrite: use write.' Also advises using line numbers from read for precision.

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