Skip to main content
Glama

patch_script

Destructive

Apply ordered literal find-and-replace hunks to one script in a single call without resending the file; use dryRun to validate first, with all-or-nothing writes.

Instructions

Apply several literal find-and-replace hunks to one script in a single call, in order, without resending the file. All or nothing: if a required hunk's text is missing, it errors and writes nothing, so a stale patch can't half-apply. Use dryRun to check first. The safest way to edit code you can quote; for a line range use edit_script_lines, and for the same change in many scripts use find_and_replace_in_scripts.

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>",
      "hunks": "<hunks>"
    },
    "name": "patch_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesScript to patch. Dot path from the DataModel root, e.g. "Workspace.Map.Door" or "StarterGui.HUD.Frame". A leading "game." is optional; a duplicate sibling name takes the suffix Tufan prints, e.g. "Part (2)".
hunksYesHunks, applied in order; each sees the result of the previous ones.
placeNoTarget place (PlaceId or project name). Defaults to the bound/sole connected place.
dryRunNoCheck that every hunk applies, without writing. Default false.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv0.1.1
    • changedInput schema / properties / dryRun / description
      Previous value: -"validate only; don't write"New value: +"Check that every hunk applies, without writing. Default false."
    • changedInput schema / properties / hunks / description
      Previous value: -"ordered hunks"New value: +"Hunks, applied in order; each sees the result of the previous ones."
    • changedInput schema / properties / hunks / items / properties / all / description
      Previous value: -"replace every occurrence (default: first only)"New value: +"Replace every occurrence. Default false: only the first."
    • changedInput schema / properties / hunks / items / properties / find / description
      Previous value: -"literal text to find"New value: +"Exact text to find, including whitespace. Not a pattern."
    • changedInput schema / properties / hunks / items / properties / optional / description
      Previous value: -"skip instead of erroring if `find` is absent"New value: +"Skip this hunk instead of failing the whole patch when find is absent. Default false."
    • changedInput schema / properties / hunks / items / properties / replace / description
      Previous value: -"replacement text"New value: +"Text to put in its place."
    • addedInput schema / properties / path / description
      Added value: +"Script to patch. Dot path from the DataModel root, e.g. \"Workspace.Map.Door\" or \"StarterGui.HUD.Frame\". A leading \"game.\" is optional; a duplicate sibling name takes the suffix Tufan prints, e.g. \"Part (2)\"."
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only declare destructiveHint=true, readOnlyHint=false and idempotentHint=false; the description goes well beyond them by explaining atomicity ("if a required hunk's text is missing, it errors and writes nothing, so a stale patch can't half-apply") and that hunks apply sequentially with each seeing prior results. This is exactly the kind of behavioral nuance annotations cannot express, and it explains why the operation is non-idempotent and destructive.

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?

Four tight sentences, front-loaded with the action and the atomicity guarantee before the alternatives. No restated parameter documentation and no filler.

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 mutating tool with no output schema, the definition covers scope (one script), ordering and atomicity guarantees, dryRun verification, and sibling routing — everything needed to invoke it safely. Only the response shape on optional-hunk skips is left implicit, which is minor.

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 every parameter (path, hunks, place, dryRun) is already documented in structured data, and the nested hunk fields (find, replace, all, optional) are fully described there. The description only adds advisory framing for dryRun ("Use dryRun to check first") rather than new semantics, so the baseline 3 applies.

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 specific verb and resource ("Apply several literal find-and-replace hunks to one script") plus the key differentiators: in-order application, single call, no file resend. It also explicitly names the two sibling tools it is not, so an agent can distinguish it from edit_script_lines and find_and_replace_in_scripts without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit routing rules with conditions: line-range edits go to edit_script_lines, the same change across many scripts goes to find_and_replace_in_scripts, and dryRun should be used to check first. Both when-to-use and when-to-use-something-else are stated.

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