launch_editor
Open the Godot editor for a project by specifying its directory path.
Instructions
Launch Godot editor for a specific project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the Godot project directory |
Implementation Reference
- src/index.ts:458-475 (registration)Registration of the 'launch_editor' tool in the setupToolHandlers method, defining its name, description, and input schema (requires projectPath).
private setupToolHandlers(): void { this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Project Management { name: 'launch_editor', description: 'Launch Godot editor for a specific project', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Godot project directory', }, }, required: ['projectPath'], }, }, - src/index.ts:856-894 (handler)The handleLaunchEditor method: validates projectPath, detects Godot path, checks for project.godot file, then spawns the Godot editor using 'godot -e --path <project>'.
private async handleLaunchEditor(args: any): Promise<ToolResult> { args = this.normalizeParameters(args); if (!args.projectPath) { return this.createErrorResponse('Project path is required'); } if (!this.validatePath(args.projectPath)) { return this.createErrorResponse('Invalid project path'); } try { if (!this.godotPath) { await this.detectGodotPath(); if (!this.godotPath) { return this.createErrorResponse('Could not find a valid Godot executable path'); } } const projectFile = join(args.projectPath, 'project.godot'); if (!existsSync(projectFile)) { return this.createErrorResponse(`Not a valid Godot project: ${args.projectPath}`); } this.logDebug(`Launching Godot editor for project: ${args.projectPath}`); const process = spawn(this.godotPath, ['-e', '--path', args.projectPath], { stdio: 'pipe', }); process.on('error', (err: Error) => { console.error('Failed to start Godot editor:', err); }); return this.createSuccessResponse(`Godot editor launched successfully for project at ${args.projectPath}.`); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return this.createErrorResponse(`Failed to launch Godot editor: ${errorMessage}`); } } - src/index.ts:465-474 (schema)Input schema for launch_editor: takes a required 'projectPath' string parameter describing the path to the Godot project directory.
inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Godot project directory', }, }, required: ['projectPath'], }, - src/index.ts:226-231 (helper)validatePath helper used by handleLaunchEditor to check path validity (rejects null/undefined and paths containing '..').
private validatePath(path: string): boolean { if (!path || path.includes('..')) { return false; } return true; } - src/index.ts:274-310 (helper)detectGodotPath helper used by handleLaunchEditor to find the Godot executable path from environment variable or common system paths.
private async detectGodotPath(): Promise<void> { if (this.godotPath && await this.isValidGodotPath(this.godotPath)) { this.logDebug(`Using existing Godot path: ${this.godotPath}`); return; } if (process.env.GODOT_PATH) { const normalizedPath = normalize(process.env.GODOT_PATH); this.logDebug(`Checking GODOT_PATH environment variable: ${normalizedPath}`); if (await this.isValidGodotPath(normalizedPath)) { this.godotPath = normalizedPath; this.logDebug(`Using Godot path from environment: ${this.godotPath}`); return; } } const osPlatform = process.platform; this.logDebug(`Auto-detecting Godot path for platform: ${osPlatform}`); const possiblePaths: string[] = ['godot']; if (osPlatform === 'darwin') { possiblePaths.push( '/Applications/Godot.app/Contents/MacOS/Godot', '/Applications/Godot_4.app/Contents/MacOS/Godot', `${process.env.HOME}/Applications/Godot.app/Contents/MacOS/Godot`, `${process.env.HOME}/Applications/Godot_4.app/Contents/MacOS/Godot`, `${process.env.HOME}/Library/Application Support/Steam/steamapps/common/Godot Engine/Godot.app/Contents/MacOS/Godot` ); } else if (osPlatform === 'win32') { possiblePaths.push( 'C:\\Program Files\\Godot\\Godot.exe', 'C:\\Program Files (x86)\\Godot\\Godot.exe', 'C:\\Program Files\\Godot_4\\Godot.exe', 'C:\\Program Files (x86)\\Godot_4\\Godot.exe', `${process.env.USERPROFILE}\\Godot\\Godot.exe` );