Skip to main content
Glama

Edit file

edit_file
Destructive

Replaces old_string with new_string in a file. old_string must match exactly (including whitespace) and be unique unless replace_all is true. Pass base (the version read_file gave) to have the edit refused with file_changed if someone changed the file after your read; then read it again and redo the edit.

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": {
      "projectId": "<projectId>",
      "path": "<path>",
      "old_string": "<old_string>",
      "new_string": "<new_string>"
    },
    "name": "edit_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
baseNoThe file's version from read_file, or null for a new file that must not exist yet. Optional
pathYes
projectIdYesProject id from list_projects
new_stringYes
old_stringYes
replace_allNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and readOnlyHint=false, so the safety profile is covered; the description goes further by disclosing the exact-match requirement (including whitespace), the uniqueness constraint, and the file_changed failure mode with a recovery procedure. It does not say what the tool returns after a successful edit, which matters for chaining subsequent edits.

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, zero filler, and the core operation is front-loaded before the constraints and the recovery workflow. The parenthetical about base is dense but earns its space.

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 six-parameter destructive mutation with no output schema, the description covers the behaviors an agent actually needs: matching rules, uniqueness, conflict handling, and the retry loop. Tool complexity is moderate and the definition meets it.

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 only 33%, but the description compensates well: it explains old_string's exact-match and uniqueness semantics, replace_all's role in relaxing uniqueness, and gives base a full behavioral explanation (version from read_file, null for a new file, conflict refusal). projectId and path are left to the schema, but they are self-evident.

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?

States a precise operation: 'Replaces old_string with new_string in a file' — specific verb and resource, and the exact-match/unique semantics immediately separate it from a whole-file write. It never explicitly contrasts itself with the sibling write_file, so an agent must infer that a full rewrite belongs elsewhere.

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?

Gives concrete conditional guidance: old_string must be unique unless replace_all is true, and base should be passed to get a conflict-checked edit. It stops short of naming alternatives or stating exclusions (e.g. when to prefer write_file), leaving that routing to inference.

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