Skip to main content
Glama

edit_file

Edit existing files by replacing exact text with new content. Applied atomically, so if any match fails, the original file remains unchanged.

Instructions

Make targeted edits to an existing file by replacing exact text. Each edit's old_string must appear exactly once (include surrounding lines to disambiguate) unless replace_all is set. All edits are applied atomically — if any anchor fails to match, the file is left untouched and you are told why. This is the preferred way to modify code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile to edit, relative to the workspace root.
editsYesEdits applied in order.
workspaceNoWorkspace alias. Defaults to the active workspace.
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals key traits: atomic application of edits, the failure behavior ('file is left untouched and you are told why'), and the uniqueness constraint on old_string. This goes beyond the schema and provides valuable safety information.

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 long, front-loaded with the main purpose, and every sentence earns its place. It conveys purpose, constraints, and preferred usage without any fluff or redundancy.

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?

The description is fairly complete given the tool's simplicity and absence of an output schema. It covers the editing behavior, atomicity, and failure feedback. It does not describe success return values, but for an edit tool this is implicit. Minor gaps like workspace defaulting are covered by the schema.

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?

Although schema coverage is 100%, the description enriches parameter semantics by explaining the uniqueness requirement for old_string, the disambiguation technique of including surrounding lines, and the atomic behavior across multiple edits. It adds constraint-level meaning that the schema alone does not convey.

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's purpose: 'Make targeted edits to an existing file by replacing exact text.' It uses a specific verb+resource+method structure and distinguishes itself from alternatives by labeling it 'the preferred way to modify code.' This clearly separates it from sibling tools like write_file or move_path.

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 clear context for when to use the tool ('preferred way to modify code') and gives specific usage guidance such as 'old_string must appear exactly once' and 'include surrounding lines to disambiguate.' However, it does not explicitly state when NOT to use it (e.g., for full-file rewrites), so it lacks explicit exclusions.

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/zcrossoverz/repo-bridge'

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