GodotLens

v1.2.0
io.github.pzalutski-pixel/godotlens Checked 3 days ago Published 1 month ago

Godot's own view of your GDScript project: code, scenes, and the running game

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

gdscript_status

Check connection status to the Godot LSP server. Returns: connection status, host, and port. Use this to verify Godot editor is running before using other tools. If disconnected, start Godot editor with your project open.

gdscript_definition

Navigate to the definition of a symbol at a given position. Returns: file path and line number where the symbol is defined. IMPORTANT: Uses ZERO-BASED coordinates (editor line 1 = pass line 0). Use when you need to find where a function, variable, or class is defined.

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number (editor line - 1)

gdscript_references

Find all references to a symbol across the entire project. Returns: list of locations (file, line, character) where the symbol is used. IMPORTANT: Uses ZERO-BASED coordinates. Essential for impact analysis before refactoring: 'What code uses this symbol?'

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number (editor line - 1)

gdscript_hover

Get type information and documentation for a symbol at a given position. Returns: type signature, documentation string, or description of the symbol. IMPORTANT: Uses ZERO-BASED coordinates. Use to understand what type a variable is, or what a function returns.

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number (editor line - 1)

gdscript_symbols

List all symbols (classes, functions, variables, signals, enums) in a file. Returns: symbol tree with name, kind, and line number for each symbol. Use to understand the structure of a file before making changes. WORKFLOW: gdscript_symbols to explore, then gdscript_hover or gdscript_definition for details.

ParameterTypeDescription
file *stringAbsolute or relative path to the .gd file

gdscript_signature_help

Get function signature and parameter information at a call site. Returns: function name, parameters with types, and return type. IMPORTANT: Uses ZERO-BASED coordinates. Use when you need to know the correct parameters for a function call.

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number (editor line - 1)

gdscript_rename

Rename a symbol across all files in the project. Returns: workspace edit with all changes needed. IMPORTANT: Uses ZERO-BASED coordinates. WORKFLOW: (1) gdscript_references to preview impact, (2) gdscript_rename to rename, (3) gdscript_sync_files to refresh LSP state.

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number (editor line - 1)
new_name *stringNew name for the symbol
old_namestringCurrent name of the symbol. Optional but recommended: enables scanning .tscn/.tres files for references Godot cannot see or update.

gdscript_sync_file

Notify Godot's LSP that a file was modified and get updated diagnostics. Returns: diagnostics (errors/warnings) for the synced file. WHEN TO CALL: After using Edit/Write tools to modify a .gd file. The LSP does not watch files, so you must call this to refresh analysis. Optionally pass content directly to avoid reading from disk.

ParameterTypeDescription
file *stringAbsolute or relative path to the modified .gd file
contentstringFile content to sync (optional, reads from disk if not provided)

gdscript_sync_files

Batch sync multiple modified files with Godot's LSP. Returns: diagnostics for all synced files. WHEN TO CALL: After modifying multiple .gd files with Edit/Write tools. More efficient than calling gdscript_sync_file repeatedly. Reads content from disk for all specified files.

ParameterTypeDescription
files *arrayList of absolute or relative paths to modified .gd files

gdscript_release_file

Release a file from the LSP session, so Godot stops serving the copy this session opened and reads from disk again. Returns: whether the file was open, and what was actually done. WHEN TO CALL: after deleting a .gd file, or when you want the LSP to forget content you synced earlier. NOTE: Godot removed its file-deletion notification in 4.6, so this cannot purge project-wide state; that clears when the editor rescans.

ParameterTypeDescription
file *stringAbsolute or relative path to the .gd file

gdscript_symbols_batch

Get symbols from multiple files in a single call. Returns: map of file path to symbol tree for each file. More efficient than calling gdscript_symbols repeatedly. Use to understand the structure of multiple files at once.

ParameterTypeDescription
files *arrayList of absolute or relative paths to .gd files

gdscript_definitions_batch

Get definitions for multiple symbol positions in a single call. Returns: list of definition locations for each position. IMPORTANT: Uses ZERO-BASED coordinates. More efficient than calling gdscript_definition repeatedly.

ParameterTypeDescription
positions *arrayList of positions to look up definitions for

gdscript_references_batch

Find references for multiple symbols in a single call. Returns: list of reference locations for each position. IMPORTANT: Uses ZERO-BASED coordinates. More efficient than calling gdscript_references repeatedly. Use for bulk impact analysis across multiple symbols.

ParameterTypeDescription
positions *arrayList of positions to find references for

gdscript_diagnostics

Get compiler errors and warnings for one or more files. Returns: list of diagnostics with line, severity (1=Error, 2=Warning, 3=Info, 4=Hint), and message. WORKFLOW: (1) Edit files, (2) gdscript_sync_files to refresh, (3) gdscript_diagnostics to check for errors. Use before committing to catch issues early.

ParameterTypeDescription
files *arrayList of absolute or relative paths to .gd files to check

gdscript_engine_api

Get authoritative documentation for a Godot ENGINE class or member, from the exact editor build in use. Returns: signature with argument names, types and defaults, plus documentation. USE THIS instead of recalling Godot's API from memory - it is the ground truth for the user's version and prevents inventing methods that do not exist. Pass 'member' for a specific method/property/signal; omit it to check a class exists.

ParameterTypeDescription
class_name *stringEngine class, e.g. CharacterBody2D
memberstringMethod, property or signal name

gdscript_complete

Get valid completions at a cursor position, from Godot's own completion engine. Returns: candidate labels with kind and detail. IMPORTANT: Uses ZERO-BASED coordinates. This is the only SCENE-AWARE query available: Godot resolves the scene that owns this script and completes against the real node, so $NodePath entries and the signals actually present on that node are included. No analysis of the .gd file alone can reproduce that.

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number
limitintegerMax items to return (default 100)

gdscript_validate

Check proposed file content for errors WITHOUT writing it to disk. Returns: valid flag, errors and warnings. WHEN TO CALL: before writing an edit, so broken code never reaches the project. The LSP is restored to the on-disk content afterwards.

ParameterTypeDescription
content *stringFull proposed file content
file *stringPath the content is intended for

gdscript_references_in_file

Find occurrences of a symbol within ONE file. Returns: list of line/char positions. IMPORTANT: Uses ZERO-BASED coordinates. Much cheaper than gdscript_references, which reparses every .gd file in the project on Godot 4.6+. Requires Godot 4.7+; reports unsupported otherwise.

ParameterTypeDescription
character *integerZero-based character position
file *stringAbsolute or relative path to the .gd file
line *integerZero-based line number

scene_state

Get Godot's own resolved view of a scene: node tree with types, script attachments, unique_name_in_owner flags, exported property values, and the signal connections declared in the scene. Godot's LSP reads .gd files only, so NONE of this is visible to gdscript_references or gdscript_rename. Runs the engine to resolve the scene, so inherited scenes and instanced children are resolved the way Godot actually instantiates them. Requires a Godot binary (GODOT_BIN or ./godot/).

ParameterTypeDescription
files *arrayScene paths, res:// or filesystem

scene_validate

Check a scene for what Godot gets silently wrong when it loads or runs it. Errors: connections to handlers or nodes that do not exist, signals the source does not have, handlers taking the wrong number of arguments, unknown node types, scripts whose base type does not fit the node, missing parents, duplicate names and duplicate unique names, and changes to nodes that do not exist in an instanced scene. Warnings: unknown properties, values of the wrong type, and NodePaths to nodes not in the scene. Returns: per-scene problems with kind, severity and detail; valid means no errors. WHEN TO CALL:…

ParameterTypeDescription
files *arrayScene paths, res:// or filesystem

debug_status

Check the connection to Godot's debug adapter and report whether the game is running, paused, or finished. The adapter is served by the Godot editor on port 6006 and needs no addon. Use this first if any debug_* tool behaves unexpectedly.

debug_output

Read what a game started with debug_run produced: print() output and stdout/stderr lines, plus structured errors - push_error, push_warning, engine errors and runtime script errors - each with file, function, ZERO-BASED line and call stack. Returns: lines, errors, and their counts. THIS IS THE ONLY WAY to see what the game actually did; the language server reports whether code compiles, not what it printed. Output and errors are drained on each call, so successive calls return only what is new.

ParameterTypeDescription
clearbooleanDrain the buffer (default true)
waitnumberSeconds to wait for output (default 1)

debug_set_breakpoints

Set breakpoints in a GDScript file, replacing any previously set in that file. Returns: each breakpoint with whether Godot verified it and the line it bound to. IMPORTANT: lines are ZERO-BASED, matching every other tool here. Set these before running the game, then use debug_stack_trace and debug_inspect once execution stops.

ParameterTypeDescription
file *stringPath to the .gd file
lines *arrayZero-based line numbers. Pass [] to clear all breakpoints in the file.

debug_stack_trace

Get the call stack where execution is currently paused. Returns: frames with function name, file and ZERO-BASED line, plus why it stopped. An empty frame list means execution is not paused - frames exist only while stopped at a breakpoint or a runtime error.

ParameterTypeDescription
thread_idintegerThread id (default 1)

debug_inspect

Inspect variables visible in a stack frame. Returns: each scope (locals, members, globals) with its variables, values and types. Use the frame_id from debug_stack_trace. Only meaningful while execution is paused.

ParameterTypeDescription
frame_id *integerFrame id from debug_stack_trace

debug_evaluate

Evaluate a GDScript expression in the context of a paused frame. Returns: the resulting value and its type. Use to check state at a breakpoint without adding print() calls and re-running.

ParameterTypeDescription
expression *stringGDScript expression
frame_idintegerFrame id from debug_stack_trace

debug_continue

Resume a paused game. Returns: confirmation.

ParameterTypeDescription
thread_idintegerThread id (default 1)

debug_pause

Pause the running game. Returns: where it stopped. Use to inspect state at an arbitrary moment rather than a preset breakpoint.

ParameterTypeDescription
thread_idintegerThread id (default 1)

debug_step_over

Step over one line in the paused game. Returns: the new stop location.

ParameterTypeDescription
thread_idintegerThread id (default 1)

debug_terminate

Stop the running game. Returns: confirmation.

gdscript_find

Find where a symbol is declared BY NAME, without needing its position. Returns: declaration sites with file, ZERO-BASED line and character, kind, and containing class. USE THIS FIRST when you know a name but not its location - the returned line/character feed directly into gdscript_references, gdscript_hover and gdscript_rename. Guessing a character offset and landing one column off returns an empty result that looks identical to 'no such symbol'. Positions come from the language server, not from text matching.

ParameterTypeDescription
name *stringExact symbol name, e.g. take_damage
filestringOptional: restrict the search to one file instead of the project
include_referencesbooleanAlso return every reference to the first declaration found
max_filesintegerCap on files inspected when searching the whole project (default 60). The response reports when the cap applied.

project_config

Get the project's resolved configuration: autoload singletons, input action names, class_name globals, and the main scene. Autoload and input action names are BARE STRINGS at the point of use - GameState.add_score(1), Input.is_action_pressed("jump") - and nothing validates them. Neither the compiler nor the language server catches a typo; it is a silent runtime no-op. Check names here before writing them. Values come from ProjectSettings via the engine, so defaults and feature-tagged overrides resolve correctly. Requires a Godot binary.

project_validate

Find references that no longer resolve, project-wide: scene and resource dependencies pointing at moved or deleted files, missing autoload scripts, and a missing main scene. Returns: broken references with the file that holds each, plus stale UIDs (Godot falls back to the text path and warns). WHEN TO CALL: after moving, renaming or deleting files. Nothing else reports these until the reference is loaded at runtime. Uses the engine's own resolution: a reference whose UID still resolves is not broken. Script preload()/extends paths are compile errors - gdscript_diagnostics reports them. Require…

debug_run

Run the project from the open Godot editor and collect what it prints. Returns: captured output, structured errors with call stacks, whether the game exited, and any stop reason. THIS CLOSES THE LOOP: edit, sync, run, and read the actual behaviour, without the developer pressing F5 or pasting console output back. The editor has ONE run slot: a second debug_run stops the first game. Set breakpoints with debug_set_breakpoints BEFORE calling this if you want execution to pause. Long-running games keep going - use debug_output to keep reading and debug_terminate to stop.

ParameterTypeDescription
argsarrayExtra engine flags appended to the game's command line, e.g. ["--headless"] to run with no window, ["--fixed-fps", "60"], ["--debug-collisions"]
collectnumberSeconds to collect output before returning (default 10)
scenestringWhich scene to run: 'main' (default), 'current', 'pinned', or a res:// path
timeoutnumberSeconds to wait for the game to start (default 60)

runtime_run

Launch the game as its own process, connected straight back to GodotLens - no editor run slot, so several agents can each run one at once. Returns: session_id, and the output and structured errors from the first seconds. Runs HEADLESS by default (no window, no sound); pass windowed=true only when you need runtime_screenshot - the window is placed off-screen and takes no focus. Script errors are reported, never stop the game. Then use runtime_tree, runtime_inspect and runtime_output to see what the game is doing. The game runs through GodotLens's helper (loaded for this run only, nothing is wri…

ParameterTypeDescription
argsarrayExtra engine flags, e.g. ['--fixed-fps', '60']
collectnumberSeconds of output to wait for (default 2)
helperbooleanRun through the helper for runtime_eval/runtime_input (default true)
resolutionstringWindow size for windowed runs, e.g. '1280x720'
scenestringres:// scene to run (default: the main scene)
timeoutnumberSeconds to wait for the game to connect (default 30)
windowedbooleanRender a real window (needed for screenshots)

runtime_stop

Stop a game started with runtime_run. Returns: exit code.

ParameterTypeDescription
session_idstringSession from runtime_run. Required only when several games run.

runtime_status

List the games GodotLens is running. Returns: each session with pid, scene, whether it is headless, running and connected, plus this server's pid.

runtime_output

Read what a running game printed and every structured error it reported since the last call - push_error, push_warning, engine and script errors, each with file, function, ZERO-BASED line and call stack. Drained on each call.

ParameterTypeDescription
session_idstringSession from runtime_run. Required only when several games run.
waitnumberSeconds to wait for more first (default 0.5)

runtime_tree

The live scene tree of a running game, including nodes created at runtime. Returns: nested nodes with name, type (script class_name or path when scripted), path, object_id and visibility. Use the path or object_id with runtime_inspect.

ParameterTypeDescription
max_depthintegerLevels below the start to include (default 8)
pathstringOnly this subtree, e.g. '/root/Main/Enemies'
session_idstringSession from runtime_run. Required only when several games run.

runtime_inspect

Current property values of one node or object in a running game, as the engine reports them. Returns: class and each property's type and value.

ParameterTypeDescription
nodestringNode path: '/root/Main/Player', 'Main/Player', or an unambiguous tail such as 'Player'
object_idintegerObject id from runtime_tree or runtime_inspect
propertiesarrayOnly these properties (default: all)
session_idstringSession from runtime_run. Required only when several games run.

runtime_set

Change a property on a node in a running game, then read it back. Values are converted to the property's own type: pass [1, 2] or 'Vector2(1, 2)' for a Vector2, '#ff0000' for a Color, a res:// path for a resource. Returns: the value the engine now reports.

ParameterTypeDescription
property *stringProperty name, e.g. position
value *New value
nodestringNode path: '/root/Main/Player', 'Main/Player', or an unambiguous tail such as 'Player'
object_idintegerObject id from runtime_tree or runtime_inspect
session_idstringSession from runtime_run. Required only when several games run.

runtime_eval

Evaluate an expression in a running game, while it runs - no breakpoint needed. Uses Godot's Expression: calls, operators, member access and constructors, no statements or assignment. Names available: the base node's members (default the current scene), autoloads, engine singletons such as Input, and class_name globals. Calls run for real and may change the game. Returns: the value, or the engine's error text.

ParameterTypeDescription
expression *stringe.g. get_tree().get_nodes_in_group("enemies").size()
nodestringBase node path for member lookups (default: current scene)
session_idstringSession from runtime_run. Required only when several games run.

runtime_input

Press an input action in a running game, as a player would: pressed for the given number of frames, then released, through the normal input path, so is_action_just_pressed and _unhandled_input see it. Actions come from the project's Input Map (project_config lists them). Returns: once released.

ParameterTypeDescription
action *stringInput Map action, e.g. jump
framesintegerFrames to hold it (default 2)
session_idstringSession from runtime_run. Required only when several games run.
strengthnumber0..1 for analog actions (default 1)

runtime_reload

Hot-reload changed scripts into a running game, keeping its state. Refuses when the language server reports errors in them: a script that fails to compile is disabled in the running game. Covers .gd scripts only - edited .tscn files and new or changed assets need a restart.

ParameterTypeDescription
files *arrayScripts to reload
session_idstringSession from runtime_run. Required only when several games run.

runtime_pause

Freeze or unfreeze a running game's scene tree. Returns: the new state.

ParameterTypeDescription
paused *booleantrue to freeze
session_idstringSession from runtime_run. Required only when several games run.

runtime_time_scale

Speed up or slow down a running game. Returns: the new scale.

ParameterTypeDescription
scale *number1.0 is normal speed
session_idstringSession from runtime_run. Required only when several games run.

runtime_step

Advance a paused game by one frame. Windowed sessions only: a headless game never draws a frame, and Godot re-pauses after the next drawn frame.

ParameterTypeDescription
session_idstringSession from runtime_run. Required only when several games run.

runtime_monitors

Performance monitors of a running game, about once a second: FPS, frame times, object, node and orphan-node counts, memory, draw calls, physics, plus any custom monitors the game registers. Returns: latest values, and a history of the requested monitors - a rising orphan count is the usual sign of a leak.

ParameterTypeDescription
namesarrayMonitors to return history for, e.g. ['OBJECT_ORPHAN_NODE_COUNT']
session_idstringSession from runtime_run. Required only when several games run.

runtime_screenshot

Capture what a windowed game is drawing. Returns: the image, with its size. Needs a session started with windowed=true; a headless game has no pixels.

ParameterTypeDescription
session_idstringSession from runtime_run. Required only when several games run.