Skip to main content
Glama

godot_get_scene_tree

Analyze Godot scene files to extract node hierarchy and parent-child relationships for development workflows.

Instructions

Inspect a saved scene and return its node hierarchy plus parent/child relationships.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath to the Godot project directory or its project.godot file.
scene_pathYesPath to the target .tscn file. Absolute, relative, and res:// paths are supported.
godot_executableNoOptional explicit path to the Godot executable or .app bundle.

Implementation Reference

  • Implementation of the get_scene_tree logic.
    def get_scene_tree(
        self,
        project_path: str,
        scene_path: str,
        godot_executable: str | None = None,
    ) -> dict[str, Any]:
        project_dir = ensure_project_path(project_path)
        executable, version = resolve_godot_executable(godot_executable)
        absolute_scene_path, resource_scene_path = resolve_scene_path(project_dir, scene_path)
    
        if not absolute_scene_path.exists():
            raise GodotError(f"Scene not found: {absolute_scene_path}")
    
        output = _run_godot_script(
            executable=executable,
            project_dir=project_dir,
            script_name="inspect_scene.gd",
            user_args=["--scene-path", resource_scene_path],
        )
        parsed = _parse_script_json_output(output, "inspect_scene.gd")
        nodes = parsed.get("nodes")
        connections = parsed.get("connections", [])
        if not isinstance(nodes, list):
            raise GodotError("Scene inspection did not return a node list.")
        if not isinstance(connections, list):
            raise GodotError("Scene inspection did not return a connection list.")
    
        normalized_nodes: list[dict[str, Any]] = []
        for node in nodes:
            if not isinstance(node, dict):
                continue
            normalized_node = dict(node)
            normalized_node["path"] = canonical_scene_node_path(str(node.get("path", ".")), ".")
            normalized_node["parent_path"] = canonical_scene_node_path(str(node.get("parent_path", "")), "")
            normalized_node["owner_path"] = canonical_scene_node_path(str(node.get("owner_path", "")), "")
            normalized_nodes.append(normalized_node)
    
        normalized_connections: list[dict[str, Any]] = []
        for connection in connections:
            if not isinstance(connection, dict):
                continue
            normalized_connection = dict(connection)
            normalized_connection["source_path"] = canonical_scene_node_path(
                str(connection.get("source_path", "")),
                "",
            )
            normalized_connection["target_path"] = canonical_scene_node_path(
                str(connection.get("target_path", "")),
                "",
            )
            normalized_connections.append(normalized_connection)
    
        return {
            "project_path": str(project_dir),
            "scene_path": str(absolute_scene_path),
            "scene_resource_path": resource_scene_path,
            "node_count": len(normalized_nodes),
            "nodes": normalized_nodes,
            "scene_tree": _build_scene_tree(normalized_nodes),
            "connections": normalized_connections,
            "godot_executable": str(executable),
            "godot_version": version,
        }
  • Registration of the godot_get_scene_tree tool in the server.
        name="godot_get_scene_tree",
        description="Inspect a saved scene and return its node hierarchy plus parent/child relationships.",
        input_schema={
            "type": "object",
            "properties": {
                "project_path": {
                    "type": "string",
                    "description": "Path to the Godot project directory or its project.godot file.",
                },
                "scene_path": {
                    "type": "string",
                    "description": "Path to the target .tscn file. Absolute, relative, and res:// paths are supported.",
                },
                "godot_executable": {
                    "type": "string",
                    "description": "Optional explicit path to the Godot executable or .app bundle.",
                },
            },
            "required": ["project_path", "scene_path"],
            "additionalProperties": False,
        },
        handler=lambda args: self.controller.get_scene_tree(
            project_path=args["project_path"],
            scene_path=args["scene_path"],
            godot_executable=args.get("godot_executable"),
        ),
    ),
Behavior2/5

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

With no annotations provided, the description carries the full burden but offers minimal behavioral insight. It doesn't disclose whether this is a read-only operation, potential errors (e.g., invalid paths), performance implications, or output format details beyond hierarchy relationships.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Inspect a saved scene') and outcome. There is no wasted verbiage or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is minimal but covers the basic purpose. However, it lacks details on behavioral traits, error handling, or output structure, leaving gaps in understanding how the tool operates in practice.

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?

The schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning about parameters beyond implying scene inspection, maintaining the baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Inspect a saved scene') and the outcome ('return its node hierarchy plus parent/child relationships'), distinguishing it from siblings like godot_get_node_properties or godot_get_project_structure that focus on different aspects of Godot projects.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid Godot project) or compare it to siblings like godot_get_project_structure for broader project analysis.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MhrnMhrn/godot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server