Skip to main content
Glama

edit_file

Destructive

Modify file content with text replacements or a unified diff while preserving original encoding and line endings. Preview changes with dry-run mode before applying.

Instructions

Edit one file with replacements or a unified diff. Returns a unified diff and keeps the file's encoding and line endings. PREFER THIS over read+write to modify a file. In 'ask before edits' mode call dryRun=true first, show the diff, then dryRun=false once the user confirms; with auto-edit permissions go straight to dryRun=false. On no match, prefer fixing oldText from the closest-content hint. Alternatively retry that edit with similarity (0.0-1.0) for whitespace/comment drift, not different code. Do NOT re-read the file afterwards to verify: a success with a diff means the edit is on disk, a failed edit changes nothing. A file with mixed line endings is repaired to its dominant style; the result says how many endings changed, so report that to the user. Parameters: path; exactly one of edits [{oldText, newText, similarity?, replaceAll?}] or patch (---/+++/@@ unified diff for one file); dryRun (default false); encoding (auto). oldText must match ONE place: several matches fail with their line numbers and change nothing — add surrounding lines to pick one, or set replaceAll: true to change them all and report the count to the user. Edits apply in order. Matching ignores per-line leading/trailing whitespace and CRLF/LF, but interior spacing must match; newText is re-indented. Example: {"path": "D:\src\unit1.pas", "edits": [{"oldText": "i: Integer;", "newText": "i: NativeInt;"}, {"oldText": "for i := 0 to 10 do", "newText": "for i := 0 to 20 do"}], "dryRun": true}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
editsNo
patchNo
dryRunNo
encodingNo
forceWritableNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed1 schema field changedv4.2.0
    • addedInput schema / properties / edits / items / properties / replaceAll
      Added value: +{
      +  "type": "boolean"
      +}
  2. Addedv3.3.0
  3. Removedv0.1.1
  4. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already show destructiveHint=true, but the description goes well beyond that by explaining exact behavior: encoding and line endings are preserved, mixed line endings are repaired to the dominant style, matching ignores leading/trailing whitespace and CRLF/LF, edits apply in order, and a failed edit changes nothing. No contradiction with annotations exists.

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?

The description is long but exceptionally dense, with the core guidance front-loaded ('Edit one file... returns a unified diff... PREFER THIS over read+write'). It is a single block rather than structured sections, but every sentence provides useful operational detail, so it earns its length.

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?

Given six parameters, no output schema, destructive behavior, and multiple sibling tools, this description is remarkably complete. It covers the return value, dry-run flow, matching edge cases, line-ending repair reporting, and no-verification rule. The only minor omission is forceWritable, but the operational workflow is fully specified.

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 0%, so the description carries the burden. It thoroughly documents path, edits, patch, dryRun, encoding, replaceAll, similarity, and matching semantics, and includes a concrete example. The only parameter not mentioned is forceWritable, so the coverage is excellent but not complete.

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 states a specific action ('Edit one file with replacements or a unified diff'), identifies its result ('Returns a unified diff'), and distinguishes it from the alternate read+write flow. It also names a sibling concept ('PREFER THIS over read+write') so the agent can differentiate it from write_file without inspecting schemas.

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 usage guidance is provided: prefer this over read+write, use dryRun=true in ask-before-editing mode, and use dryRun=false with auto-edit permissions. It also gives recovery guidance on no-match ('prefer fixing oldText... Alternatively retry with similarity') and tells the agent not to re-read the file afterward.

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

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/dimitar-grigorov/mcp-file-tools'

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