Skip to main content
Glama

patch_file

Destructive

Replace exact text inside a UTF-8 file within allowlisted development folders. Use it to apply precise, targeted edits to project files without rewriting entire contents.

Instructions

Replace exact text inside a UTF-8 file in an allowlisted development folder.

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>",
      "search": "<search>",
      "replace": "<replace>"
    },
    "name": "patch_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes
searchYes
replaceYes
replace_allNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.1/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false, idempotentHint=false and openWorldHint=false, so the safety profile is structured. The description adds the UTF-8 assumption and the allowlist scope, but omits critical behavior: what happens when the search text is missing or matches multiple times, and whether a backup or atomic write occurs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence, front-loaded with the verb and action, and no filler. It is efficient but under-sized for a destructive four-parameter tool, so brevity trades against usefulness rather than excess wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation with no output schema and no documented parameters, the definition leaves too much unsaid: match-count semantics, no-match error behavior, allowlist failure mode, and whether the edit is atomic. The single sentence does not give an agent enough to invoke it safely on the first try.

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

Parameters2/5

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

Schema description coverage is 0% across four parameters, so the description must carry the load. It gives meaning to path (allowlisted folder) and search (exact text), but says nothing about replace_all's default of false or whether the default behavior replaces only the first occurrence — the single most consequential ambiguity for a destructive edit.

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 specific verb and resource ('Replace exact text inside a UTF-8 file') plus a scope constraint (allowlisted development folder), which separates it from a whole-file write such as write_file. It does not clarify the granularity of replacement (first match vs. all matches), so purpose is clear but not fully precise.

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?

Targeted-edit intent is implied by 'replace exact text,' which suggests use over write_file when only a small fragment changes. There is no explicit when-to-use or when-not, and no statement of the precondition that the file must be inside an allowlisted folder before calling.

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