Skip to main content
Glama

Add Node to Scene

godot_add_node

Add a new node to a Godot scene by specifying its type, name, and parent path. This tool helps developers build scene hierarchies and configure node properties directly within the Godot editor.

Instructions

Adds a new node of the specified type as a child of the given parent node.

Args:

  • parent_path (string): Node path of the parent e.g. "/root/Main"

  • node_type (string): Godot class name e.g. "Sprite2D", "CharacterBody2D", "Label", "AudioStreamPlayer"

  • node_name (string): Name for the new node

  • scene_path (string, optional): Scene to modify. Defaults to active scene.

  • properties (object, optional): Initial property values to set on the new node.

Returns: { name, type, path } of the created node.

Examples:

  • Use when: "Add a Sprite2D called PlayerSprite under /root/Main"

  • Use when: "Add a Label node to the HUD with text 'Score: 0'"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parent_pathYesNode path of the parent node
node_typeYesGodot class name for the new node
node_nameYesName for the new node
scene_pathNoScene to modify. Omit for active scene.
propertiesNoInitial property key/value pairs

Implementation Reference

  • The handler function that executes the godot_add_node tool. It extracts parameters, makes a POST request to the Godot client at '/scene/node', and returns the created node information.
    async ({ parent_path, node_type, node_name, scene_path, properties }) => {
      const result = await godotRequest<GodotNodeInfo>("POST", "/scene/node", {
        parent_path, node_type, node_name, scene_path, properties
      });
      return {
        content: [{ type: "text", text: `Node created: ${JSON.stringify(result, null, 2)}` }]
      };
    }
  • The input validation schema using Zod for godot_add_node. Defines required fields (parent_path, node_type, node_name) and optional fields (scene_path, properties).
    inputSchema: z.object({
      parent_path: z.string().describe("Node path of the parent node"),
      node_type: z.string().describe("Godot class name for the new node"),
      node_name: z.string().describe("Name for the new node"),
      scene_path: z.string().optional().describe("Scene to modify. Omit for active scene."),
      properties: z.record(z.unknown()).optional().describe("Initial property key/value pairs")
    }).strict(),
  • The complete registration of the godot_add_node tool with MCP server, including title, description, input schema, annotations, and the handler function.
      server.registerTool(
        "godot_add_node",
        {
          title: "Add Node to Scene",
          description: `Adds a new node of the specified type as a child of the given parent node.
    
    Args:
      - parent_path (string): Node path of the parent e.g. "/root/Main"
      - node_type (string): Godot class name e.g. "Sprite2D", "CharacterBody2D", "Label", "AudioStreamPlayer"
      - node_name (string): Name for the new node
      - scene_path (string, optional): Scene to modify. Defaults to active scene.
      - properties (object, optional): Initial property values to set on the new node.
    
    Returns:
      { name, type, path } of the created node.
    
    Examples:
      - Use when: "Add a Sprite2D called PlayerSprite under /root/Main"
      - Use when: "Add a Label node to the HUD with text 'Score: 0'"`,
          inputSchema: z.object({
            parent_path: z.string().describe("Node path of the parent node"),
            node_type: z.string().describe("Godot class name for the new node"),
            node_name: z.string().describe("Name for the new node"),
            scene_path: z.string().optional().describe("Scene to modify. Omit for active scene."),
            properties: z.record(z.unknown()).optional().describe("Initial property key/value pairs")
          }).strict(),
          annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
        },
        async ({ parent_path, node_type, node_name, scene_path, properties }) => {
          const result = await godotRequest<GodotNodeInfo>("POST", "/scene/node", {
            parent_path, node_type, node_name, scene_path, properties
          });
          return {
            content: [{ type: "text", text: `Node created: ${JSON.stringify(result, null, 2)}` }]
          };
        }
      );
  • The godotRequest helper function used by the handler to make HTTP requests to the Godot MCP Bridge. Handles errors, connection issues, and response parsing.
    export async function godotRequest<T>(
      method: "GET" | "POST" | "PUT" | "DELETE",
      path: string,
      body?: unknown
    ): Promise<T> {
      try {
        const response = await client.request<ApiResponse<T>>({
          method,
          url: path,
          data: body
        });
    
        const payload = response.data;
        if (!payload.success) {
          throw new Error(payload.error ?? "Godot returned an unsuccessful response.");
        }
        return payload.data as T;
      } catch (err) {
        if (axios.isAxiosError(err)) {
          const axErr = err as AxiosError<ApiResponse<unknown>>;
          if (axErr.code === "ECONNREFUSED") {
            throw new Error(
              `Cannot connect to Godot at ${GODOT_BASE_URL}. ` +
              `Make sure the MCP Bridge plugin is enabled and the project is running ` +
              `(Project > Tools > MCP Bridge > Start Server).`
            );
          }
          const serverMsg = axErr.response?.data?.error;
          throw new Error(serverMsg ?? axErr.message);
        }
        throw err;
      }
    }
Behavior4/5

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

Annotations indicate this is a non-readOnly, non-destructive mutation tool. The description adds valuable context beyond annotations: it specifies that it modifies scenes (with a default to active scene), describes the return format ({name, type, path}), and implies creation of new nodes rather than duplication. No contradictions with annotations exist.

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 well-structured with clear sections (purpose, Args, Returns, Examples), front-loads the core functionality, and every sentence adds value. No redundant or verbose elements are present.

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

Completeness4/5

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

For a mutation tool with no output schema, the description provides good context: it explains the action, parameters, return format, and usage examples. However, it doesn't cover potential errors (e.g., invalid parent paths) or side effects (e.g., scene modification state), leaving minor gaps in completeness.

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?

With 100% schema description coverage, the schema already documents all parameters thoroughly. The description adds minimal extra meaning (e.g., examples of node_type values like 'Sprite2D', 'CharacterBody2D'), but doesn't significantly enhance understanding beyond the schema. This meets the baseline for high schema coverage.

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 ('Adds a new node') and resource ('as a child of the given parent node'), distinguishing it from siblings like godot_remove_node (removal) and godot_reparent_node (reparenting). The verb 'adds' is precise and the scope is well-defined.

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

Usage Guidelines4/5

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

The 'Examples' section provides clear context for when to use this tool (e.g., adding specific node types with names), but it doesn't explicitly state when NOT to use it or mention alternatives like godot_instantiate_scene for instantiating existing scenes. The guidance is helpful but lacks exclusion criteria.

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/ricky-yosh/godot-mcp-server'

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