run_script
Run custom GDScript in a live Godot project with full scene tree access. Scripts return JSON-serialized values.
Instructions
Execute a custom GDScript in the live running project with full scene tree access. Requires run_project first. Script must extend RefCounted and define func execute(scene_tree: SceneTree) -> Variant. Return values are JSON-serialized (primitives, Vector2/3, Color, Dictionary, Array, and Node path strings are supported). Use print() for debug output — it appears in get_debug_output, not in the script result. In spawned mode, runtime errors emitted to stderr are detected and either escalated (when the script returns null) or surfaced as warnings. In attached mode a null result includes a caveat since stderr is not captured.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | GDScript source code. Must contain "extends RefCounted" and "func execute(scene_tree: SceneTree) -> Variant". | |
| timeout | No | Timeout in ms (default: 30000). Increase for long-running scripts. |