Skip to main content
Glama

Edit file

edit_file

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.1/5.0
Behavior4/5

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

The annotations only declare readOnlyHint=false and destructiveHint=false; the description adds the non-obvious behavior that matters — exact-match brittleness, uniqueness enforcement, optimistic-concurrency failure with the file_changed error code, and what to do after that failure. It still does not say whether a missing file is created or what the tool returns on success.

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, front-loaded with the core replacement semantics before the matching rules and the failure/recovery path. No filler, and each clause carries operational information an agent needs.

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 mutating file tool with no output schema and only partial schema descriptions, this covers the failure modes and preconditions an agent is most likely to hit. The remaining gap is the success path (return value, whether new files can be created), which the schema only hints at via the base parameter's null case.

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%, yet the description carries real meaning for the hardest parameters: old_string must match exactly including whitespace and be unique, replace_all lifts the uniqueness constraint, and base is the version token that triggers a file_changed refusal. path and new_string are left to the schema, so it is not exhaustive.

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?

"Replaces old_string with new_string in a file" is a specific verb+resource pair that tells an agent exactly what the operation does. However, it never distinguishes itself from the sibling tool write_file, which is the obvious alternative for the same resource; the description only references read_file as the source of the version token.

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?

It gives clear situational guidance for the optional base parameter: pass the version from read_file when you want concurrent-modification protection, and the exact recovery loop (re-read, redo the edit). What it does not state is when to pick this tool over write_file, so a nearby alternative remains ambiguous.

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