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
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path for the new scene | |
| rootType | Yes | Godot type for the root node | |
| rootName | Yes | Name for the root node |
Implementation Reference
- src/tools/scene-edit-tools.ts:668-725 (handler)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"), }, - src/tools/scene-edit-tools.ts:661-662 (registration)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.",