Skip to main content
Glama

create_scene

Generate a new Godot scene file with a specified root node type and name for game development projects.

Instructions

Create a brand new empty .tscn scene file with just a root node.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path for the new scene
rootTypeYesGodot type for the root node
rootNameYesName for the root node

Implementation Reference

  • The handler function for the create_scene tool which creates and writes a new .tscn file.
    handler: async (ctx) => {
      const { path: filePath, rootType, rootName } = ctx.args;
      validatePath(filePath);
    
      try {
        const scene: SceneInfo = {
          filePath,
          rootType,
          rootName,
          nodes: new Map(),
          signalConnections: [],
          instancedScenes: [],
          externalResources: [],
          subResources: [],
          contentHash: "",
          rawSource: "",
        };
    
        const root: NodeInfo = {
          name: rootName,
          type: rootType,
          scenePath: filePath,
          nodePath: rootName,
          parent: null,
          children: [],
          script: null,
          groups: [],
          properties: {},
          isInstanceOf: null,
          rawSpan: null,
        };
    
        scene.nodes.set(rootName, root);
    
        if (ctx.signal?.aborted) {
          throw new GodotteError(ErrorCode.TOOL_TIMEOUT, "Write aborted: tool timed out");
        }
        const output = serializeTscn(scene);
        await writeFile(filePath, output, "utf-8");
    
        await eventBus.emit("file:changed", {
          path: filePath,
          type: "created",
        });
    
        return makeTextResponse({
          data: {
            path: filePath,
            rootType,
            rootName,
          },
          metadata: { source: "index" },
        });
      } catch (err) {
        return makeTextResponse({
          error: `Failed to create scene: ${(err as Error).message}`,
          data: null,
        });
  • The input schema for the create_scene tool.
    schema: {
      path: z.string().describe("File path for the new scene"),
      rootType: z.string().describe("Godot type for the root node"),
      rootName: z.string().describe("Name for the root node"),
    },
  • Registration of the create_scene tool within the createSceneEditTools function.
    name: "create_scene",
    description: "Create a brand new empty .tscn scene file with just a root node.",

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