Skip to main content
Glama

edit_file

Edit text and code files with intelligent matching strategies. Supports single-file or batch multi-file edits with dry-run preview and atomic rollback.

Instructions

Apply precise modifications to text and code files with intelligent matching.

Single File Editing (mode: 'single'): Edit one file with multiple sequential edits using exact, flexible, or fuzzy matching strategies.

Multi-File Editing (mode: 'multiple'): Edit multiple files concurrently in a single operation. Each file can have its own edit configuration.

Matching Strategies:

  1. Exact: Character-for-character match (fastest, safest)

  2. Flexible: Whitespace-insensitive, preserves original indentation

  3. Fuzzy: Token-based regex matching for maximum compatibility

Features:

  • Concurrent processing for multi-file operations

  • Per-file matching strategy control

  • Dry-run preview mode

  • Detailed diff output with statistics

  • Atomic operations with rollback capability

  • Cross-platform line ending preservation

Maximum: 50 files per multi-file operation

Best Practices:

  • Include 3-5 lines of context before and after the change for reliability

  • Add 'instruction' field to describe the purpose of each edit

  • Use 'dryRun: true' to preview changes before applying

  • For multiple related changes, use array of edits (applied sequentially)

  • Set 'expectedOccurrences' to validate replacement count

  • Use 'matchingStrategy' to control matching behavior (defaults to 'auto')

CRITICAL - Multi-line Content:

  • Use actual newline characters in oldText/newText strings, NOT \n escape sequences

  • The MCP/JSON layer handles encoding automatically

  • Using \n literally will search for/write backslash+n characters (wrong!)

Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoEdit mode: 'single' for one file, 'multiple' for batch editingsingle
pathNoPath to file (required for single mode)
editsNoArray of edits to apply
filesNoArray of file edit requests (required for multiple mode)
failFastNoStop processing on first file failure (true) or continue with remaining files (false)
matchingStrategyNoMatching strategy: - 'exact': Strict character-for-character match (fastest, safest) - 'flexible': Whitespace-insensitive line-by-line matching - 'fuzzy': Token-based regex matching (most permissive) - 'auto': Try exact → flexible → fuzzy (recommended, default)auto
dryRunNoPreview changes without writing
failOnAmbiguousNoIf true, fail when oldText matches multiple locations (unless expectedOccurrences > 1). If false, replace first occurrence only and warn about ambiguity.
Behavior4/5

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

With no annotations, the description carries full burden. It discloses atomic operations with rollback, concurrent processing, cross-platform line ending preservation, and a maximum of 50 files per operation. It mentions dry-run preview mode and matching strategies. However, it could be more explicit that the tool writes to disk and is potentially destructive if oldText matches incorrectly.

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 well-organized with sections for modes, matching strategies, features, and best practices. It front-loads the core purpose. Each sentence adds information, though slight trimming of redundant phrases (e.g., 'per-file matching strategy control' in Features) could improve conciseness.

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

Completeness3/5

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

Given the tool's complexity and no output schema, the description mentions 'detailed diff output with statistics' but does not specify the exact return structure. It covers modes, strategies, and best practices adequately, but lacks explicit error handling details beyond ambiguous matches. Overall, it is sufficient for an agent to use correctly, but gaps remain in output information.

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. The description adds significant value by explaining matching strategies, best practices for oldText/newText, and the purpose of instruction and expectedOccurrences fields. It also provides critical guidance on multi-line content representation.

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 explicitly states the tool applies precise modifications to text and code files, details single and multi-file editing modes, and outlines matching strategies. It clearly distinguishes from sibling tools like write_file (which overwrites entire files) and delete_files.

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?

Best practices are provided (e.g., include 3-5 lines of context, use dryRun, set expectedOccurrences). A critical note about multi-line content warnings against using \n. It implicitly advises against using this tool for complete file rewrites (use write_file). However, it does not explicitly state when NOT to use this tool.

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/n0zer0d4y/vulcan-file-ops'

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