Skip to main content
Glama
fs-mcp-server

fs-mcp-server

by qsrahman

Edit File

edit_file
Destructive

Make line-based text file edits by replacing exact oldText with newText in order, with optional replaceAll and dry-run diff preview. Writes nothing if any edit fails to match.

Instructions

Make line-based edits to a text file, applied in order: each replaces oldText with newText. oldText must match exactly one place (add surrounding lines to make it unique) unless replaceAll is set. When there is no exact match, line endings and leading/trailing whitespace on whole lines are ignored. If any edit has no match or an ambiguous one, nothing is written. Returns a git-style diff.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "edits": "<edits>"
    },
    "name": "edit_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesAbsolute path, or relative to the server's working directory.
editsYesThe replacements, applied in order.
dryRunNoIf true, return the diff without changing the file (default false).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.6.1
    • changedInput schema / properties / dryRun / description
      Previous value: -"Preview changes using git-style diff format"New value: +"If true, return the diff without changing the file (default false)."
    • changedInput schema / properties / edits / description
      Previous value: -"The replacements to make, applied in order. Each oldText must match exactly one place unless replaceAll is set."New value: +"The replacements, applied in order."
    • changedInput schema / properties / edits / items / properties / newText / description
      Previous value: -"Text to replace with"New value: +"Replacement text; empty to delete the matched text."
    • changedInput schema / properties / edits / items / properties / oldText / description
      Previous value: -"Text to search for - must match exactly"New value: +"Text to find, copied exactly from the file."
  2. First observedv0.3.0

TDQS

A4.2/5.0
Behavior5/5

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

Beyond the annotations (which only declare destructive/not-read-only), it discloses the atomicity contract — if any edit fails to match or is ambiguous, nothing is written — plus whitespace and line-ending tolerance and a git-style diff return. That is exactly the mutation-risk context an agent needs and cannot get from structured fields.

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?

Three tight sentences, front-loaded with the core action, then match rules, then the all-or-nothing guarantee and return value. No sentence is filler and nothing is buried.

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?

For a 3-parameter mutating tool with no output schema, the description covers the action, match semantics, failure mode, and return format. Nothing an agent needs to invoke it correctly is missing.

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%, so baseline is 3, but the description adds real semantics: edits are applied in order, oldText must be unique unless replaceAll is set, and match tolerance rules. It adds value above the schema without redundantly restating it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ("line-based edits to a text file") and immediately explains the applied-in-order replacement mechanism, so an agent knows exactly what operation it is. It does not explicitly contrast with siblings like write_file or shell, which keeps it from a 5.

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

Usage Guidelines3/5

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

Usage is implied rather than stated: the emphasis on exact-match oldText and atomic failure signals this is for targeted patches, and the caller is told to add surrounding lines for uniqueness. There is no explicit when-to-use-this-instead-of-write_file guidance or named alternative.

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