Skip to main content
Glama

add_to_group

Add a node to a group in Godot .tscn scene files to organize and manage scene elements for game development workflows.

Instructions

Add a node to a group in a .tscn scene file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sceneYesPath to the .tscn file
nodePathYesNode path within the scene
groupYesGroup name to add
expectedHashNoExpected content hash for stale-edit prevention

Implementation Reference

  • The handler implementation for 'add_to_group', which reads the scene, validates the hash, ensures the node exists, checks if the group is already present, and updates the group list for the node.
    handler: async (ctx) => {
      const { scene: scenePath, nodePath, group, expectedHash } = ctx.args;
      validatePath(scenePath);
    
      return withFileLock(scenePath, async () => {
        try {
          const { source, scene } = await readAndParse(scenePath);
          const hashErr = hashCheck(source, expectedHash);
          if (hashErr) return makeTextResponse({ error: hashErr, data: null });
    
          const node = scene.nodes.get(nodePath);
          if (!node) {
            return makeTextResponse({
              error: `Node not found: ${nodePath}`,
              data: null,
            });
          }
    
          if (node.groups.includes(group)) {
            return makeTextResponse({
              error: `Node is already in group: ${group}`,
              data: null,
            });
          }
    
          node.groups.push(group);
    
          await writeAndEmit(scenePath, scene, eventBus, ctx.signal);
    
          return makeTextResponse({
            data: {
              nodePath,
              group,
              groups: node.groups,
            },
            metadata: { source: "index" },
          });
        } catch (err) {
          return makeTextResponse({
            error: `Failed to add to group: ${(err as Error).message}`,
            data: null,
          });
        }
      });
    },
  • The schema definition for 'add_to_group', including the required scene path, node path, and group name, with an optional expected hash.
    schema: {
      scene: z.string().describe("Path to the .tscn file"),
      nodePath: z.string().describe("Node path within the scene"),
      group: z.string().describe("Group name to add"),
      expectedHash: z
        .string()
        .optional()
        .describe("Expected content hash for stale-edit prevention"),
    },
  • The registration of the 'add_to_group' tool in the tools array.
    {
      name: "add_to_group",
      description: "Add a node to a group in a .tscn scene file.",

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/woohq/godette-mcp'

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