Skip to main content
Glama

get_uid

Retrieve the unique identifier (UID) for files in Godot 4.4+ projects to enable precise asset referencing and management.

Instructions

Get the UID for a specific file in a Godot project (for Godot 4.4+)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the Godot project directory
filePathYesPath to the file (relative to project) for which to get the UID

Implementation Reference

  • The handler function that implements the get_uid tool logic. Validates inputs, checks Godot 4.4+ compatibility, executes the Godot operations script with 'get_uid' command.
    private async handleGetUid(args: any) { // Normalize parameters to camelCase args = this.normalizeParameters(args); if (!args.projectPath || !args.filePath) { return this.createErrorResponse( 'Missing required parameters', ['Provide projectPath and filePath'] ); } if (!this.validatePath(args.projectPath) || !this.validatePath(args.filePath)) { return this.createErrorResponse( 'Invalid path', ['Provide valid paths without ".." or other potentially unsafe characters'] ); } try { // Ensure godotPath is set if (!this.godotPath) { await this.detectGodotPath(); if (!this.godotPath) { return this.createErrorResponse( 'Could not find a valid Godot executable path', [ 'Ensure Godot is installed correctly', 'Set GODOT_PATH environment variable to specify the correct path', ] ); } } // Check if the project directory exists and contains a project.godot file const projectFile = join(args.projectPath, 'project.godot'); if (!existsSync(projectFile)) { return this.createErrorResponse( `Not a valid Godot project: ${args.projectPath}`, [ 'Ensure the path points to a directory containing a project.godot file', 'Use list_projects to find valid Godot projects', ] ); } // Check if the file exists const filePath = join(args.projectPath, args.filePath); if (!existsSync(filePath)) { return this.createErrorResponse( `File does not exist: ${args.filePath}`, ['Ensure the file path is correct'] ); } // Get Godot version to check if UIDs are supported const { stdout: versionOutput } = await execAsync(`"${this.godotPath}" --version`); const version = versionOutput.trim(); if (!this.isGodot44OrLater(version)) { return this.createErrorResponse( `UIDs are only supported in Godot 4.4 or later. Current version: ${version}`, [ 'Upgrade to Godot 4.4 or later to use UIDs', 'Use resource paths instead of UIDs for this version of Godot', ] ); } // Prepare parameters for the operation (already in camelCase) const params = { filePath: args.filePath, }; // Execute the operation const { stdout, stderr } = await this.executeOperation('get_uid', params, args.projectPath); if (stderr && stderr.includes('Failed to')) { return this.createErrorResponse( `Failed to get UID: ${stderr}`, [ 'Check if the file is a valid Godot resource', 'Ensure the file path is correct', ] ); } return { content: [ { type: 'text', text: `UID for ${args.filePath}: ${stdout.trim()}`, }, ], }; } catch (error: any) { return this.createErrorResponse( `Failed to get UID: ${error?.message || 'Unknown error'}`, [ 'Ensure Godot is installed correctly', 'Check if the GODOT_PATH environment variable is set correctly', 'Verify the project path is accessible', ] ); } }
  • The input schema definition for the get_uid tool, specifying required projectPath and filePath parameters.
    name: 'get_uid', description: 'Get the UID for a specific file in a Godot project (for Godot 4.4+)', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Godot project directory', }, filePath: { type: 'string', description: 'Path to the file (relative to project) for which to get the UID', }, }, required: ['projectPath', 'filePath'], }, },
  • src/index.ts:958-959 (registration)
    Registration of the get_uid tool handler in the CallToolRequestSchema switch statement, dispatching to handleGetUid.
    case 'get_uid': return await this.handleGetUid(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