list_projects
Find Godot projects in a directory, with optional recursive search to locate projects in subfolders.
Instructions
List Godot projects in a directory
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | Directory to search for Godot projects | |
| recursive | No | Whether to search recursively (default: false) |
Implementation Reference
- src/index.ts:1012-1029 (handler)The main handler function handleListProjects that executes the list_projects tool logic. It validates the 'directory' argument, calls findGodotProjects, and returns the results.
private async handleListProjects(args: any): Promise<ToolResult> { args = this.normalizeParameters(args); if (!args.directory) { return this.createErrorResponse('Directory is required'); } try { const projects = this.findGodotProjects(args.directory, args.recursive || false); return this.createSuccessResponse( `Found ${projects.length} Godot project(s):`, projects ); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return this.createErrorResponse(`Failed to list projects: ${errorMessage}`); } } - src/index.ts:1320-1372 (helper)The helper function findGodotProjects that recursively/iteratively searches for project.godot files in the given directory and returns project paths and names.
private findGodotProjects(directory: string, recursive: boolean): Array<{ path: string; name: string }> { const projects: Array<{ path: string; name: string }> = []; try { const projectFile = join(directory, 'project.godot'); if (existsSync(projectFile)) { projects.push({ path: directory, name: basename(directory), }); } if (!recursive) { const entries = readdirSync(directory, { withFileTypes: true }); for (const entry of entries) { if (entry.isDirectory()) { const subdir = join(directory, entry.name); const projectFile = join(subdir, 'project.godot'); if (existsSync(projectFile)) { projects.push({ path: subdir, name: entry.name, }); } } } } else { const entries = readdirSync(directory, { withFileTypes: true }); for (const entry of entries) { if (entry.isDirectory()) { const subdir = join(directory, entry.name); if (entry.name.startsWith('.')) { continue; } const projectFile = join(subdir, 'project.godot'); if (existsSync(projectFile)) { projects.push({ path: subdir, name: entry.name, }); } else { const subProjects = this.findGodotProjects(subdir, true); projects.push(...subProjects); } } } } } catch (error) { this.logDebug(`Error searching directory ${directory}: ${error}`); } return projects; } - src/index.ts:521-538 (schema)The tool registration schema for list_projects, defining its name, description, and input schema with 'directory' (required string) and 'recursive' (optional boolean) parameters.
{ name: 'list_projects', description: 'List Godot projects in a directory', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Directory to search for Godot projects', }, recursive: { type: 'boolean', description: 'Whether to search recursively (default: false)', }, }, required: ['directory'], }, }, - src/index.ts:799-801 (registration)The case statement in the tool dispatch switch that routes 'list_projects' requests to handleListProjects.
case 'list_projects': result = await this.handleListProjects(request.params.arguments); break;