Skip to main content
Glama

Script Patch

script_patch

Replace exact code snippets in Godot .gd or .cs files, with GDScript validation and in-memory refresh for immediate execution.

Instructions

Anchor-based string-replace edit on a .gd or .cs file.

Finds an exact old_text and replaces with new_text. Fails on multiple matches unless replace_all=True; fails on zero matches. Exact byte match (whitespace significant). Triggers filesystem scan. .gd: parse-validated (diagnostics) and an already-loaded GDScript is refreshed in place so the next call runs the new code (response reloaded=true; otherwise reload_reason says why). .cs: text only — diagnostics_status="not_checked", reload_reason= "csharp_requires_build"; rebuild the .NET assembly to run it. Not undoable via Ctrl+Z.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesres:// path ending in .gd or .cs.
new_textYesReplacement (empty deletes).
old_textYesExact substring to find. Must be unique unless replace_all.
session_idNoOptional Godot session to target. Empty = active session.
replace_allNoReplace every occurrence. Default False.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv4.2.1
    • changedInput schema / properties / path / description
      Previous value: -"res:// path ending in .gd."New value: +"res:// path ending in .gd or .cs."
  2. Addedv3.1.4
  3. Removedv3.0.7
  4. First observedv2.9.1

TDQS

A4.3/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and does an excellent job. It discloses exact byte matching, failure modes, filesystem scan triggering, GDScript vs C# reload behavior, diagnostics handling, and the fact that the edit is not undoable via Ctrl+Z.

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?

The description is dense but every sentence earns its place, covering purpose, failure modes, language-specific behavior, reload semantics, and undo limitations. It is front-loaded with the core action and then expands into necessary details.

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?

Given the tool has an output schema and full parameter coverage, the description supplies the missing behavioral context: failure conditions, reload behavior, filesystem scan side effect, and non-undoability. An agent has enough information to invoke it correctly without consulting siblings.

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 the schema already documents all five parameters. The description reinforces exact-match behavior and mentions empty-deletes semantics, but adds only marginal precision beyond what the schema provides.

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?

The description names a specific verb and resource: an anchor-based string-replace edit on .gd or .cs files. It clearly distinguishes itself from siblings like script_create, script_attach, and script_manage by describing an in-place patch operation.

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?

The behavioral conditions are explicit: exact match, failure on zero or multiple matches, and different post-edit behavior for .gd vs .cs. However, it never names alternatives or explicitly says when script_patch should be chosen over script_create, script_attach, or script_manage, so the routing is left to inference.

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