update_project_uids
Update UID references in Godot projects by resaving resources. Resolves broken references after moving or renaming files (Godot 4.4+).
Instructions
Update UID references in a Godot project by resaving resources (for Godot 4.4+)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the Godot project directory |
Implementation Reference
- src/index.ts:1262-1285 (handler)Handler function that executes the 'update_project_uids' tool logic. Validates projectPath, then delegates to executeOperation which runs a Godot script with the operation name.
private async handleUpdateProjectUids(args: any): Promise<ToolResult> { args = this.normalizeParameters(args); if (!args.projectPath) { return this.createErrorResponse('Project path is required'); } try { const { stdout, stderr } = await this.executeOperation( 'update_project_uids', {}, args.projectPath ); if (stderr && stderr.includes('ERROR')) { return this.createErrorResponse(`Failed to update UIDs: ${stderr}`); } return this.createSuccessResponse(`Project UIDs updated successfully`, stdout); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return this.createErrorResponse(`Failed to update UIDs: ${errorMessage}`); } } - src/index.ts:730-743 (schema)Tool registration with input schema definition for 'update_project_uids'. Defines the name, description, and inputSchema requiring 'projectPath' (string).
{ name: 'update_project_uids', description: 'Update UID references in a Godot project by resaving resources (for Godot 4.4+)', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Godot project directory', }, }, required: ['projectPath'], }, }, - src/index.ts:826-828 (registration)Switch-case dispatch that routes the 'update_project_uids' tool call to the handler handleUpdateProjectUids.
case 'update_project_uids': result = await this.handleUpdateProjectUids(request.params.arguments); break; - src/index.ts:391-440 (helper)executeOperation helper method that runs the actual Godot script. It takes an operation name and parameters, builds a Godot command line with --headless --path --script, and executes it.
private async executeOperation( operation: string, params: OperationParams, projectPath: string ): Promise<{ stdout: string; stderr: string }> { this.logDebug(`Executing operation: ${operation} in project: ${projectPath}`); this.logDebug(`Original operation params: ${JSON.stringify(params)}`); const snakeCaseParams = this.convertCamelToSnakeCase(params); this.logDebug(`Converted snake_case params: ${JSON.stringify(snakeCaseParams)}`); if (!this.godotPath) { await this.detectGodotPath(); if (!this.godotPath) { throw new Error('Could not find a valid Godot executable path'); } } try { const paramsJson = JSON.stringify(snakeCaseParams); const args = [ '--headless', '--path', projectPath, '--script', this.operationsScriptPath, operation, paramsJson, ]; if (GODOT_DEBUG_MODE) { args.push('--debug-godot'); } this.logDebug(`Executing: ${this.godotPath} ${args.join(' ')}`); const { stdout, stderr } = await execFileAsync(this.godotPath!, args); return { stdout: stdout ?? '', stderr: stderr ?? '' }; } catch (error: unknown) { if (error instanceof Error && 'stdout' in error && 'stderr' in error) { const execError = error as Error & { stdout: string; stderr: string }; return { stdout: execError.stdout ?? '', stderr: execError.stderr ?? '', }; } throw error;