Skip to main content
Glama

run_script

Destructive

Execute GDScript inside a running Godot 4 game to inspect or manipulate the live scene tree, with optional timeout and JSON-serialized results.

Instructions

Run GDScript in the running game. It must extend RefCounted and define func execute(scene_tree: SceneTree) -> Variant; execute may await, cut off at the timeout (not cancelled). Return is JSON-serialized: vectors as {x,y[,z,w]}, Color as {r,g,b,a}, a Node as {class,name,path}. Compiled with project warnings. Returns: projectPath, result, warnings, tip. Spawned: a runtime error is an error if result is null, else a warning. Attached: errors are unobservable. Asks the user once per project.

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": {
      "script": "<script>"
    },
    "name": "run_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
scriptYesGDScript source code. Must contain "extends RefCounted" and "func execute(scene_tree: SceneTree) -> Variant".
timeoutNoTimeout in ms, a whole number from 1 to 600000 (default: 30000); a value from 59001 to 60000 is refused, since the answer would not fit a client's 60s request timeout. Increase for long-running scripts. Time spent on the confirmation prompt and waiting for the session queue comes off it; a call left with under 2000 ms is refused with nothing sent.

Output Schema

NameRequiredDescriptionDefault
tipYes
resultYesThe value execute returned. Vector2, Vector3 and Vector4 (and their int forms) are {x, y[, z, w]}, Color is {r, g, b, a}, and a packed array is a plain array of its elements, the shapes get_node_properties returns. A non-finite number (INF, NAN) is null and counted in warnings. Rect2, Quaternion, transforms and other types without a shape of their own are their text form (null and counted when a component is non-finite). A Node is {class, name, path}, a Resource {class, path}, another Object its text, a freed Object "<Freed Object>".
warningsNo
projectPathYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv4.0.1
    • changedInput schema / properties / timeout / description
      Previous value: -"Timeout in ms (default: 30000). Increase for long-running scripts."New value: +"Timeout in ms, a whole number from 1 to 600000 (default: 30000); a value from 59001 to 60000 is refused, since the answer would not fit a client's 60s request timeout. Increase for long-running scripts. Time spent on the confirmation prompt and waiting for the session queue comes off it; a call left with under 2000 ms is refused with nothing sent."
    • addedInput schema / properties / timeout / maximum
      Added value: +600000
    • addedInput schema / properties / timeout / minimum
      Added value: +1
    • changedInput schema / properties / timeout / type
      Previous value: -"number"New value: +"integer"
    • addedOutput schema / properties / projectPath
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / result / description
      Added value: +"The value execute returned. Vector2, Vector3 and Vector4 (and their int forms) are {x, y[, z, w]}, Color is {r, g, b, a}, and a packed array is a plain array of its elements, the shapes get_node_properties returns. A non-finite number (INF, NAN) is null and counted in warnings. Rect2, Quaternion, transforms and other types without a shape of their own are their text form (null and counted when a component is non-finite). A Node is {class, name, path}, a Resource {class, path}, another Object its text, a freed Object \"<Freed Object>\"."
    • removedOutput schema / properties / success
      Removed value: -{
      -  "type": "boolean"
      -}
    • addedOutput schema / required
      Added value: +[
      +  "projectPath",
      +  "result",
      +  "tip"
      +]
  2. Changed1 schema field changedv3.2.0
    • removedOutput schema / properties / warning
      Removed value: -{
      -  "type": "string"
      -}
  3. Addedv3.1.1
  4. Removedv3.0.0
  5. Addedv1.0.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations only declare destructiveHint=true, yet the description adds substantial context: a per-project user confirmation prompt, wall-clock budget shared with the prompt and session queue, refusal thresholds, and non-cancellation at timeout. It also discloses asymmetric error semantics (spawned errors surface via null result; attached errors are unobservable), which annotations alone would not reveal. It stops short of noting assumptions about which game/session it attaches to, but is far richer than the annotation baseline.

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?

Front-loaded with the action and the required script contract, then compactly enumerates return serialization, failure modes, and prompting. The telegraphic "Spawned:/Attached:" fragments are dense but earn their place; little is wasted.

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?

Given a 2-parameter schema, an output schema, and a destructive tool with side effects, the description covers the risks (arbitrary code execution, user prompt, unobservable attached errors) and timeout behavior well. The return-format sentence is partly redundant with the output schema, and guidance relative to attach_script is absent.

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 coverage is 100% and the timeout parameter is already exhaustively documented in the schema, so the description only adds the nuance that execute may await and is cut off (not cancelled) at the timeout. Helpful, but largely restating structured data, so 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?

States a specific verb and resource ("Run GDScript in the running game") and pins down the required contract (extends RefCounted, func execute(scene_tree)). An agent knows exactly what the tool does, though it never names the obvious alternative attach_script to differentiate the two.

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?

Usage is implied by statements like "Increase for long-running scripts" and by the spawned-vs-attached error contrast, but it never explicitly says when to prefer run_script over attach_script or over a plain run_project. No exclusions or prerequisites stated beyond the script contract.

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