Evaluate GDScript
godot_evalExecute GDScript code in a running Godot game and return the result as a string. Supports autoload singletons, method calls, and async operations.
Instructions
Run GDScript in the running game and return the result as a string. The code is compiled as a real script, so autoload singletons (e.g. GameState), method calls and await all work. A bare expression is auto-wrapped to return its value; multi-line code should return explicitly. The locals tree (SceneTree), root (Window) and scene (current scene) are provided. Examples: "GameState.last_health", "scene.get_node("Player").position", "return await some_node.some_async()".
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": {
"expression": "<expression>"
},
"name": "godot_eval"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_id | No | Handle of a running game (e.g. "game-1"). Optional when exactly one game is running. | |
| expression | Yes | GDScript to run: a bare expression, or statements ending in `return`. | |
| response_format | No | Output format. "markdown" is human-readable; "json" is structured. | markdown |