get_project_info
Retrieve metadata from a Godot project directory, including project settings and configuration details.
Instructions
Retrieve metadata about a Godot project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the Godot project directory |
Implementation Reference
- src/index.ts:1031-1059 (handler)Handler for get_project_info tool: validates projectPath, reads project.godot config, retrieves project structure, and returns path, name, structure, and config as JSON.
private async handleGetProjectInfo(args: any): Promise<ToolResult> { args = this.normalizeParameters(args); if (!args.projectPath) { return this.createErrorResponse('Project path is required'); } try { const projectFile = join(args.projectPath, 'project.godot'); if (!existsSync(projectFile)) { return this.createErrorResponse(`Not a valid Godot project: ${args.projectPath}`); } const projectContent = readFileSync(projectFile, 'utf-8'); const structure = await this.getProjectStructure(args.projectPath); const info = { path: args.projectPath, name: basename(args.projectPath), structure, config: projectContent.substring(0, 1000), // First 1000 chars }; return this.createSuccessResponse('Project info:', info); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return this.createErrorResponse(`Failed to get project info: ${errorMessage}`); } } - src/index.ts:539-552 (schema)Schema definition for get_project_info tool: requires a single string parameter 'projectPath'.
{ name: 'get_project_info', description: 'Retrieve metadata about a Godot project', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Godot project directory', }, }, required: ['projectPath'], }, }, - src/index.ts:802-803 (registration)Registration dispatch for 'get_project_info' tool name to its handler method.
case 'get_project_info': result = await this.handleGetProjectInfo(request.params.arguments); - src/index.ts:1374-1416 (helper)Helper that scans the project directory and categorizes subdirectories into scenes, scripts, assets, and other.
private async getProjectStructure(projectPath: string): Promise<any> { try { const entries = readdirSync(projectPath, { withFileTypes: true }); const structure: any = { scenes: [], scripts: [], assets: [], other: [], }; for (const entry of entries) { if (entry.isDirectory()) { const dirName = entry.name.toLowerCase(); if (dirName.startsWith('.')) { continue; } if (dirName === 'scenes' || dirName.includes('scene')) { structure.scenes.push(entry.name); } else if (dirName === 'scripts' || dirName.includes('script')) { structure.scripts.push(entry.name); } else if ( dirName === 'assets' || dirName === 'textures' || dirName === 'models' || dirName === 'sounds' || dirName === 'music' ) { structure.assets.push(entry.name); } else { structure.other.push(entry.name); } } } return structure; } catch (error) { this.logDebug(`Error getting project structure: ${error}`); return { error: 'Failed to get project structure' }; } } - src/index.ts:206-224 (helper)Helper that formats the successful tool response, converting data to pretty-printed JSON.
private createSuccessResponse(message: string, data?: any): ToolResult { const response: ToolResult = { content: [ { type: 'text', text: message, }, ], }; if (data !== undefined) { response.content.push({ type: 'text', text: typeof data === 'string' ? data : JSON.stringify(data, null, 2), }); } return response; }