Skip to main content
Glama

Edit a file

files_edit
Destructive

Change PART of a file by replacing an exact snippet, leaving the rest untouched. Prefer this over files.write for any edit to an existing file: rewriting a whole file to change a few lines is slow, expensive and loses anything you did not repeat. The snippet must appear EXACTLY once unless you pass replaceAll.

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": {
      "id": "<id>",
      "path": "<path>",
      "oldString": "<oldString>",
      "newString": "<newString>"
    },
    "name": "files_edit"
  }
}

Input Schema

NameRequiredDescriptionDefault
idYes
pathYesREQUIRED. The file to edit, volume-root relative, e.g. '/index.js'.
newStringYesWhat to put in its place. An empty string deletes the snippet.
oldStringYesThe exact text to replace, copied from the file including its indentation.
replaceAllNoReplace every occurrence instead of requiring exactly one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and idempotentHint=false, so the safety profile is covered. The description adds genuinely new behavioral constraints: the snippet must match exactly once unless replaceAll is set, implying a hard failure mode on ambiguous matches. It does not spell out what error or response results from a non-unique or missing match, which keeps it below a 5.

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 sentences, each doing distinct work: what it does, why to prefer it over the alternative, and the matching constraint. The routing guidance and the uniqueness rule are both front-loaded with no filler.

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?

For a destructive mutation tool with no output schema, the definition covers purpose, alternative, and the key failure condition, with annotations handling reversibility. The only real gap is the required 'id' parameter, which neither schema nor description explains, and no mention of what a failed match returns.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 80%, so the schema already documents path, oldString, newString and replaceAll, including that an empty newString deletes. The description reinforces the uniqueness semantics tied to oldString and replaceAll but adds little that the schema does not already say. The undescribed 'id' parameter is not clarified either, so this sits at the baseline.

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?

States a precise verb and resource with explicit scope: 'Change PART of a file by replacing an exact snippet, leaving the rest untouched.' This immediately separates it from whole-file writes and from sibling mutation tools like files_move or files_delete.

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?

Gives an explicit routing rule — 'Prefer this over files.write for any edit to an existing file' — plus the reason (slow, expensive, loses unrepeated content). An agent knows both when to use this tool and which sibling to avoid without opening either schema.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources