Skip to main content
Glama

edit_file

Replaces every exact match of a target string in a file, including matching whitespace, with new text; an empty replacement deletes the matched text.

Instructions

Replace every exact occurrence of Target in a file. Target must match the file text, including whitespace.

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>",
      "Target": "<Target>",
      "Replacement": "<Replacement>"
    },
    "name": "edit_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
PathYesAbsolute path of the file.
TargetYesExact text to replace.
ReplacementYesText to put in place of Target. Empty deletes it.
ArtifactMetadataNoIgnored. Omit for ordinary files.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden and does disclose two important traits: replacement applies to every occurrence, not just the first, and the match must be exact including whitespace. It omits what happens on no-match (error vs. no-op), whether the file is rewritten atomically, and encoding/normalization behavior, which matter for an in-place mutation.

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?

Two short sentences, zero filler, with the scope of the operation front-loaded before the matching constraint. Nothing could be removed without losing information.

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 simple three-required-parameter file mutation with a full schema and an output schema, the description covers the critical semantic (global replace) and the matching rule. Only the failure mode for a non-matching Target and any guidance versus write_file are missing, which is a modest gap rather than a blocking one.

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 description coverage is 100%, so Path, Target, Replacement, and the ignored ArtifactMetadata parameter are all already documented, including that an empty Replacement deletes text. The description only reinforces Target's exactness, adding no new parameter-level meaning; baseline 3 applies.

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 gives a specific verb and resource ("Replace every exact occurrence of Target in a file") and makes the all-occurrences semantics explicit. It does not name the natural sibling (write_file) to contrast whole-file overwrite versus in-place replacement, so sibling differentiation is left to inference.

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?

"Target must match the file text, including whitespace" is a real usage constraint that tells the agent when a call will succeed. However, there is no guidance on when to prefer this tool over write_file or run_command, and no exclusion or prerequisite statement beyond the match requirement.

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