How hi-godot/godot-ai works
1. System shape: This repo is a two-process bridge between a live Godot editor and external MCP clients. The Godot-side plugin runs inside the editor, while the Python package exposes the MCP server over HTTP and forwards execution to the editor over WebSocket.
2. Primary request flow: An MCP client sends tool/resource requests to http://127.0.0.1:8000/mcp. The Python server accepts those requests, translates them into editor actions, and sends them through the WebSocket connection on the Godot side. The editor plugin then performs the actual work against Godot APIs such as EditorInterface, SceneTree, and resource/node/script APIs.
3. Godot plugin boundary: plugin/addons/godot_ai is the editor extension. Core entry points like plugin.gd, connection.gd, dispatcher.gd, and mcp_dock.gd manage plugin lifecycle, server connectivity, dispatching, and the dock UI. The dock is the user-facing control plane for server status, client setup, logs, and troubleshooting.
4. Python server boundary: src/godot_ai is the MCP-facing runtime. server.py, asgi.py, transport/websocket.py, and transport/origin_guard.py define the network layer; sessions/registry.py, runtime/direct.py, and orphan_reaper.py manage server/session lifecycle and cleanup. This side is responsible for request routing, guarding origins, and keeping the bridge healthy.
5. Tooling model: The repo is organized by Godot domain, not by UI pages. Under src/godot_ai/tools and src/godot_ai/handlers you get tool endpoints for scene, node, script, filesystem, project, editor, UI, audio, camera, animation, material, particles, signals, input maps, autoloads, and testing. The Python tools layer is the MCP contract; the handlers layer contains the actual operation logic and validation.
6. Resource model: src/godot_ai/resources exposes structured MCP resources for editor/project state such as scenes, scripts, nodes, classes, library data, editor state, and sessions. These are the read-oriented counterpart to tools and are used for discovery, inspection, and pagination-heavy queries.
7. Validation and safety: Several layers enforce safety before editor changes happen: middleware/* normalizes and validates inputs, protocol/* defines envelopes and errors, utils/path_validator.gd and related helpers guard file/path access, and origin_guard.py restricts inbound transport origins. This matters architecturally because the system is effectively remote-controlling an editor, not just calling local functions.
8. Client configuration subsystem: The plugin includes a large client-adaptation layer under plugin/addons/godot_ai/clients, with per-client strategies for Claude Code, Claude Desktop, Cursor, Zed, VS Code, Windsurf, Gemini CLI, etc. client_configurator.gd and the dock panels generate or rewrite the client-side MCP config so external assistants can connect to the local server without manual editing.
9. Observability and runtime support: plugin/addons/godot_ai/runtime, telemetry.gd, and the Python telemetry.py provide logging, structured diagnostics, and anonymous usage telemetry. Supporting utilities like server_lifecycle, server_version_check, update_manager, and uv_cache_cleanup exist because the plugin is responsible for starting, restarting, and recovering the embedded server process reliably.
10. Testing strategy: The repository is split between Python tests in tests/ and Godot integration coverage in test_project/. The test_project folder is a self-contained Godot app used to exercise plugin behavior, editor interactions, and GDScript-side runtime behavior, while tests/integration and tests/unit validate the Python server, transport, protocol, and safety contracts.
11. Build and release posture: The repo is packaged as a Godot addon plus a separately installed Python server. GitHub workflows, script/* helpers, and docs like packaging-distribution.md and testing-strategy.md indicate that release artifacts are validated for both the plugin layout under addons/godot_ai and the Python runtime versioning/compatibility expected by MCP clients.
Main entry points: asgi.py ASGI app · server.py MCP server · transport Transport · tests Python tests
Components 21
Godot plugin
Editor-side addon running inside the Godot editor.
- Plugin entry · Registers the editor plugin and wires startup/shutdown.
plugin/addons/godot_ai/plugin.gd - Connection · Manages server connectivity and bridge state.
plugin/addons/godot_ai/connection.gd - Dispatcher · Routes incoming actions to the right editor-side handlers.
plugin/addons/godot_ai/dispatcher.gd - MCP dock · Control panel for status, setup, logs, and troubleshooting.
plugin/addons/godot_ai/mcp_dock.gd - Client setup · Generates or rewrites MCP client configs for external assistants.
plugin/addons/godot_ai/clients - Editor handlers · Domain handlers that execute scene, node, script, filesystem, and editor actions.
plugin/addons/godot_ai/handlers - Plugin utils · Validation, path guards, lifecycle helpers, logging, updates, and serialization.
plugin/addons/godot_ai/utils - Plugin runtime · Runtime helpers and telemetry used while the addon is active.
plugin/addons/godot_ai/runtime
Python server
MCP-facing runtime that bridges clients to the editor.
- MCP server · Entry point for the Python-side MCP runtime.
src/godot_ai/server.py - ASGI app · Exposes the HTTP surface that MCP clients call.
src/godot_ai/asgi.py - Transport · WebSocket bridge and origin filtering for editor connections.
src/godot_ai/transport - Sessions · Tracks connected editors and server session lifecycle.
src/godot_ai/sessions - Runtime mode · Direct runtime path used to execute or forward work toward the editor.
src/godot_ai/runtime - Tool handlers · Tool endpoints for scene, node, script, filesystem, project, UI, and domain-specific actions.
src/godot_ai/handlers - Tool catalog · Defines tool surfaces, pagination, domains, and meta-tool wiring.
src/godot_ai/tools - Resources · Read-oriented MCP resources for scenes, scripts, nodes, project state, classes, and sessions.
src/godot_ai/resources - Middleware · Normalizes inputs, handles parameter coercion, and improves error reporting.
src/godot_ai/middleware - Protocol · Shared request/response envelope definitions and error taxonomy.
src/godot_ai/protocol - Godot client · Client bridge used by the server to talk to the live editor process.
src/godot_ai/godot_client
Testing
Godot integration project and Python test suites.
- Test project · Self-contained Godot project used to exercise plugin behavior and editor interactions.
test_project - Python tests · Unit and integration coverage for server, transport, protocol, and safety contracts.
tests
Connections 24
- Plugin entry → Connection: initializes · Plugin startup sets up bridge connectivity.
- Plugin entry → MCP dock: creates UI · Plugin installs the editor dock and control surfaces.
- Connection → Dispatcher: forwards actions · Connected requests are dispatched into editor operations.
- Dispatcher → Editor handlers: invokes · Dispatcher routes work to domain handlers.
- Editor handlers → Plugin utils: validates · Handlers rely on path and input guards before mutating state.
- MCP dock → Client setup: configures clients · Dock and configurator generate external MCP client setup.
- MCP dock → Plugin runtime: shows logs · UI exposes runtime diagnostics and telemetry state.
- MCP server → ASGI app: serves · Server hosts the HTTP entry point for MCP clients.
- ASGI app → Middleware: passes through · Incoming requests are normalized and validated.
- Middleware → Protocol: uses · Middleware relies on shared envelope and error definitions.
- ASGI app → Tool catalog: advertises · Tool definitions form the MCP contract surface.
- ASGI app → Resources: serves · Read-only resources are exposed to clients.
- Tool catalog → Tool handlers: binds to · Tool definitions map onto handler implementations.
- Resources → Tool handlers: reads via · Resource lookups reuse domain handlers and state access.
- MCP server → Transport: bridges over · Editor communication happens through transport layer websockets.
- Transport → Godot client: connects · Transport binds the remote editor client connection.
- MCP server → Sessions: tracks · Server keeps session registry and lifecycle state.
- Sessions → Runtime mode: coordinates · Session state drives direct runtime execution mode.
- Runtime mode → Tool handlers: executes · Runtime invokes the operational handlers.
- Transport → Protocol: encodes · Transport uses protocol envelopes and error handling.
- Test project → Plugin entry: exercises · Integration project validates addon lifecycle and editor behavior.
- Python tests → MCP server: verifies · Python suites cover server, transport, resources, and tools.
- Python tests → Transport: checks · Tests cover origin guard and websocket behavior.
- Python tests → Protocol: asserts · Tests validate protocol and error contracts.