run_project
Run a Godot project from a specified path, optionally with a scene, and capture the output for debugging or monitoring.
Instructions
Run the Godot project and capture output
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the Godot project directory | |
| scene | No | Optional: Specific scene to run |
Implementation Reference
- src/index.ts:896-966 (handler)The handleRunProject method: spawns a Godot process in debug mode with --path, optional scene, captures stdout/stderr, manages active process lifecycle, and returns a success/error response.
private async handleRunProject(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 { const projectFile = join(args.projectPath, 'project.godot'); if (!existsSync(projectFile)) { return this.createErrorResponse(`Not a valid Godot project: ${args.projectPath}`); } if (this.activeProcess) { this.logDebug('Killing existing Godot process before starting a new one'); this.activeProcess.process.kill(); } const cmdArgs = ['-d', '--path', args.projectPath]; if (args.scene && this.validatePath(args.scene)) { this.logDebug(`Adding scene parameter: ${args.scene}`); cmdArgs.push(args.scene); } this.logDebug(`Running Godot project: ${args.projectPath}`); const process = spawn(this.godotPath!, cmdArgs, { stdio: 'pipe' }); const output: string[] = []; const errors: string[] = []; process.stdout?.on('data', (data: Buffer) => { const lines = data.toString().split('\n'); output.push(...lines); lines.forEach((line: string) => { if (line.trim()) this.logDebug(`[Godot stdout] ${line}`); }); }); process.stderr?.on('data', (data: Buffer) => { const lines = data.toString().split('\n'); errors.push(...lines); lines.forEach((line: string) => { if (line.trim()) this.logDebug(`[Godot stderr] ${line}`); }); }); process.on('exit', (code: number | null) => { this.logDebug(`Godot process exited with code ${code}`); if (this.activeProcess && this.activeProcess.process === process) { this.activeProcess = null; } }); process.on('error', (err: Error) => { console.error('Failed to start Godot process:', err); if (this.activeProcess && this.activeProcess.process === process) { this.activeProcess = null; } }); this.activeProcess = { process, output, errors }; return this.createSuccessResponse('Godot project started in debug mode. Use get_debug_output to see output.'); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return this.createErrorResponse(`Failed to run Godot project: ${errorMessage}`); } } - src/index.ts:476-493 (registration)Tool registration for 'run_project' with description and inputSchema (projectPath required, scene optional).
{ name: 'run_project', description: 'Run the Godot project and capture output', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Godot project directory', }, scene: { type: 'string', description: 'Optional: Specific scene to run', }, }, required: ['projectPath'], }, }, - src/index.ts:787-789 (registration)Switch case dispatching the 'run_project' tool request to handleRunProject.
case 'run_project': result = await this.handleRunProject(request.params.arguments); break;