Skip to main content
Glama

list_projects

Find and display Godot projects within a specified directory to help users locate and manage their game development files.

Instructions

List Godot projects in a directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory to search for Godot projects
recursiveNoWhether to search recursively (default: false)

Implementation Reference

  • Handler function for the 'list_projects' tool. Validates input directory, calls findGodotProjects helper, and returns JSON list of projects.
    private async handleListProjects(args: any) { // Normalize parameters to camelCase args = this.normalizeParameters(args); if (!args.directory) { return this.createErrorResponse( 'Directory is required', ['Provide a valid directory path to search for Godot projects'] ); } if (!this.validatePath(args.directory)) { return this.createErrorResponse( 'Invalid directory path', ['Provide a valid path without ".." or other potentially unsafe characters'] ); } try { this.logDebug(`Listing Godot projects in directory: ${args.directory}`); if (!existsSync(args.directory)) { return this.createErrorResponse( `Directory does not exist: ${args.directory}`, ['Provide a valid directory path that exists on the system'] ); } const recursive = args.recursive === true; const projects = this.findGodotProjects(args.directory, recursive); return { content: [ { type: 'text', text: JSON.stringify(projects, null, 2), }, ], }; } catch (error: any) { return this.createErrorResponse( `Failed to list projects: ${error?.message || 'Unknown error'}`, [ 'Ensure the directory exists and is accessible', 'Check if you have permission to read the directory', ] ); } }
  • Input schema and registration for the 'list_projects' tool in the ListTools response.
    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'], },
  • Core helper function that implements the logic to find Godot projects by searching for 'project.godot' files in directories, supporting recursive search.
    private findGodotProjects(directory: string, recursive: boolean): Array<{ path: string; name: string }> { const projects: Array<{ path: string; name: string }> = []; try { // Check if the directory itself is a Godot project const projectFile = join(directory, 'project.godot'); if (existsSync(projectFile)) { projects.push({ path: directory, name: basename(directory), }); } // If not recursive, only check immediate subdirectories 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 { // Recursive search const entries = readdirSync(directory, { withFileTypes: true }); for (const entry of entries) { if (entry.isDirectory()) { const subdir = join(directory, entry.name); // Skip hidden directories if (entry.name.startsWith('.')) { continue; } // Check if this directory is a Godot project const projectFile = join(subdir, 'project.godot'); if (existsSync(projectFile)) { projects.push({ path: subdir, name: entry.name, }); } else { // Recursively search this directory const subProjects = this.findGodotProjects(subdir, true); projects.push(...subProjects); } } } } } catch (error) { this.logDebug(`Error searching directory ${directory}: ${error}`); } return projects; }
  • src/index.ts:944-945 (registration)
    Dispatch/registration in the CallToolRequestSchema switch statement that routes calls to the list_projects handler.
    case 'list_projects': return await this.handleListProjects(request.params.arguments);

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/Coding-Solo/godot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server