Skip to main content
Glama

update_project_uids

Update UID references in Godot projects by resaving resources to maintain compatibility with Godot 4.4+ versions.

Instructions

Update UID references in a Godot project by resaving resources (for Godot 4.4+)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the Godot project directory

Implementation Reference

  • Handler function for 'update_project_uids' tool. Validates projectPath, checks Godot version (requires 4.4+), executes 'resave_resources' operation via Godot script to update UIDs by resaving resources, handles errors.
     * Handle the update_project_uids tool
     */
    private async handleUpdateProjectUids(args: any) {
      // Normalize parameters to camelCase
      args = this.normalizeParameters(args);
      
      if (!args.projectPath) {
        return this.createErrorResponse(
          'Project path is required',
          ['Provide a valid path to a Godot project directory']
        );
      }
    
      if (!this.validatePath(args.projectPath)) {
        return this.createErrorResponse(
          'Invalid project path',
          ['Provide a valid path 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',
            ]
          );
        }
    
        // 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 = {
          projectPath: args.projectPath,
        };
    
        // Execute the operation
        const { stdout, stderr } = await this.executeOperation('resave_resources', params, args.projectPath);
    
        if (stderr && stderr.includes('Failed to')) {
          return this.createErrorResponse(
            `Failed to update project UIDs: ${stderr}`,
            [
              'Check if the project is valid',
              'Ensure you have write permissions to the project directory',
            ]
          );
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Project UIDs updated successfully.\n\nOutput: ${stdout}`,
            },
          ],
        };
      } catch (error: any) {
        return this.createErrorResponse(
          `Failed to update project UIDs: ${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',
          ]
        );
      }
    }
  • Input schema for update_project_uids tool: requires 'projectPath' as string.
      type: 'object',
      properties: {
        projectPath: {
          type: 'string',
          description: 'Path to the Godot project directory',
        },
      },
      required: ['projectPath'],
    },
  • src/index.ts:914-926 (registration)
    Registration of update_project_uids tool in ListTools response, including name, description, and input schema.
      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:960-961 (registration)
    Handler registration in CallToolRequestSchema switch statement maps 'update_project_uids' to handleUpdateProjectUids method.
    case 'update_project_uids':
      return await this.handleUpdateProjectUids(request.params.arguments);
  • Shared helper method executeOperation that runs Godot headless with operations script (godot_operations.gd), passing 'resave_resources' as operation for this tool to perform UID updates.
    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)}`);
    
      // Convert camelCase parameters to snake_case for Godot script
      const snakeCaseParams = this.convertCamelToSnakeCase(params);
      this.logDebug(`Converted snake_case params: ${JSON.stringify(snakeCaseParams)}`);
    
    
      // Ensure godotPath is set
      if (!this.godotPath) {
        await this.detectGodotPath();
        if (!this.godotPath) {
          throw new Error('Could not find a valid Godot executable path');
        }
      }
    
      try {
        // Serialize the snake_case parameters to a valid JSON string
        const paramsJson = JSON.stringify(snakeCaseParams);
        // Escape single quotes in the JSON string to prevent command injection
        const escapedParams = paramsJson.replace(/'/g, "'\\''");
        // On Windows, cmd.exe does not strip single quotes, so we use
        // double quotes and escape them to ensure the JSON is parsed
        // correctly by Godot.
        const isWindows = process.platform === 'win32';
        const quotedParams = isWindows
          ? `\"${paramsJson.replace(/\"/g, '\\"')}\"`
          : `'${escapedParams}'`;
    
    
        // Add debug arguments if debug mode is enabled
        const debugArgs = GODOT_DEBUG_MODE ? ['--debug-godot'] : [];
    
        // Construct the command with the operation and JSON parameters
        const cmd = [
          `"${this.godotPath}"`,
          '--headless',
          '--path',
          `"${projectPath}"`,
          '--script',
          `"${this.operationsScriptPath}"`,
          operation,
          quotedParams, // Pass the JSON string as a single argument
          ...debugArgs,
        ].join(' ');
    
        this.logDebug(`Command: ${cmd}`);
    
        const { stdout, stderr } = await execAsync(cmd);
    
        return { stdout, stderr };
      } catch (error: unknown) {
        // If execAsync throws, it still contains stdout/stderr
        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;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It states the tool updates UIDs by resaving resources, implying a mutation operation, but doesn't clarify permissions needed, whether changes are destructive or reversible, or what the response looks like. This is a significant gap for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the purpose, method, and version constraint. It is appropriately sized and front-loaded, earning its place without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., side effects, error handling) and return values, which are critical for an agent to use it correctly. The high schema coverage doesn't compensate for these gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents the single parameter 'projectPath'. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Update UID references') and the resource ('a Godot project'), specifying it's done by 'resaving resources' and targeting 'Godot 4.4+'. It distinguishes from siblings like 'get_uid' or 'save_scene' by focusing on UID updates rather than retrieval or general saving, though it doesn't explicitly contrast with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'save_scene' or 'run_project', nor does it mention prerequisites (e.g., project state) or exclusions. It implies usage for Godot 4.4+ projects but lacks context on specific scenarios or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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