Skip to main content
Glama

edit_file

Destructive

Replace an exact string in a PHP file for targeted edits, with syntax checking before disk write so parse errors reject broken changes.

Instructions

Edit a file by replacing an exact string. old_string must match exactly and uniquely unless replace_all is true. The preferred way to change an existing .php file — a targeted replacement can't corrupt the surrounding file the way a full rewrite can. Result is syntax-checked before it touches disk; a broken edit is rejected with the parse error instead of being saved.

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

Input Schema

NameRequiredDescriptionDefault
pathYes
new_stringYes
old_stringYes
replace_allNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.2

TDQS

A4.4/5.0
Behavior4/5

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

Adds real behavior beyond the destructiveHint annotation: exact-and-unique match requirement, syntax checking before disk write, and rejection with the parse error rather than saving a broken file. That is meaningful mutation-safety context. It stops short of covering permissions, atomicity, or what happens to line endings and encoding.

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?

Front-loads the mechanism in the first sentence, then requirements, then the value proposition and safety guarantee. Every sentence carries distinct information 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 four-parameter mutation tool with no output schema and only a destructiveHint annotation, the description supplies the essential constraints and failure behavior. The remaining gap is path semantics, such as whether the path is relative to the site root or a sandbox, which the agent must infer.

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?

With 0% schema description coverage the description carries the load, and it explains the two non-obvious parameters well: old_string must match exactly and uniquely, and replace_all relaxes the uniqueness requirement. path and new_string get no explicit meaning, though their names and the surrounding text make them largely self-evident.

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 concrete verb and resource plus the exact mechanism: replacing an exact string. It also implicitly but clearly distinguishes itself from a full-rewrite tool (write_file) by explaining that a targeted replacement can't corrupt surrounding content, so an agent can pick between them without reading either schema.

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?

Explicitly frames itself as the preferred way to modify an existing .php file, and gives the uniqueness constraint plus the replace_all escape hatch. It does not state exclusions, e.g. that new files should go through write_file or that deleting content belongs to delete_file, so the guidance is clear but not complete.

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