Skip to main content
Glama

sage_edit_file

Perform exact string replacement in a file, returning a compact change preview and preserving pre-edit content for undo. Requires a unique match or sets replace_all to true.

Instructions

Exact string replacement in a file. Returns a compact change preview instead of the whole file, and snapshots the pre-edit content for undo. old must match exactly and be unique unless replace_all=true.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
newYesReplacement (empty deletes)
oldYesExact string to replace
pathYesFile to edit
replace_allNo
Behavior5/5

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

With no annotations, the description fully bears the burden of behavioral disclosure. It clearly states that the tool returns a compact change preview instead of the full file and snapshots pre-edit content for undo. It also explains the uniqueness constraint and replace_all behavior. These details give the agent a comprehensive understanding of the tool's operation beyond just purpose.

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 three sentences, each serving a clear purpose: stating the action, describing the output and undo feature, and setting the uniqueness constraint. No extraneous words. The most important information (exact replacement) is front-loaded. Perfectly concise.

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 the tool's complexity (file editing with preview and undo) and the absence of an output schema or annotations, the description covers essential aspects: purpose, behavior, and constraints. It lacks details about error handling (e.g., what happens if old string is not found) and details about the preview format, but the core information is sufficient for effective use. A score of 4 reflects good coverage with minor gaps.

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 75% (3 of 4 parameters have descriptions). The description adds value beyond the schema by explaining that 'old' must be exact and unique unless replace_all is true, and that 'new' can be empty to delete. This provides crucial binding context that the schema does not convey. The extra nuance justifies a score above the baseline of 3.

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 'Exact string replacement in a file', which is a specific verb and resource. It distinguishes itself from siblings like sage_write_file (whole file) and sage_agentic_fix (autonomous fix) by focusing on precise, targeted edits. The mention of replace_all further clarifies its unique behavior.

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

Usage Guidelines4/5

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

The description provides implicit usage context: it is for precise string replacements with preview and undo features. It explicitly states constraints (old must match exactly and be unique unless replace_all=true). However, it does not compare directly to sibling tools or explicitly state when not to use this tool, missing a small opportunity for clearer guidance.

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/PsYcGoD/sage'

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