Skip to main content
Glama

load_sprite

Load a texture into a Sprite2D node within a Godot scene to display images in your game project.

Instructions

Load a sprite into a Sprite2D node

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the Godot project directory
scenePathYesPath to the scene file (relative to project)
nodePathYesPath to the Sprite2D node (e.g., "root/Player/Sprite2D")
texturePathYesPath to the texture file (relative to project)

Implementation Reference

  • Handler function that validates input parameters, checks file existences, prepares parameters, executes the 'load_sprite' Godot operation, and handles responses or errors.
    private async handleLoadSprite(args: any) {
      // Normalize parameters to camelCase
      args = this.normalizeParameters(args);
      
      if (!args.projectPath || !args.scenePath || !args.nodePath || !args.texturePath) {
        return this.createErrorResponse(
          'Missing required parameters',
          ['Provide projectPath, scenePath, nodePath, and texturePath']
        );
      }
    
      if (
        !this.validatePath(args.projectPath) ||
        !this.validatePath(args.scenePath) ||
        !this.validatePath(args.nodePath) ||
        !this.validatePath(args.texturePath)
      ) {
        return this.createErrorResponse(
          'Invalid path',
          ['Provide valid paths without ".." or other potentially unsafe characters']
        );
      }
    
      try {
        // 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 scene file exists
        const scenePath = join(args.projectPath, args.scenePath);
        if (!existsSync(scenePath)) {
          return this.createErrorResponse(
            `Scene file does not exist: ${args.scenePath}`,
            [
              'Ensure the scene path is correct',
              'Use create_scene to create a new scene first',
            ]
          );
        }
    
        // Check if the texture file exists
        const texturePath = join(args.projectPath, args.texturePath);
        if (!existsSync(texturePath)) {
          return this.createErrorResponse(
            `Texture file does not exist: ${args.texturePath}`,
            [
              'Ensure the texture path is correct',
              'Upload or create the texture file first',
            ]
          );
        }
    
        // Prepare parameters for the operation (already in camelCase)
        const params = {
          scenePath: args.scenePath,
          nodePath: args.nodePath,
          texturePath: args.texturePath,
        };
    
        // Execute the operation
        const { stdout, stderr } = await this.executeOperation('load_sprite', params, args.projectPath);
    
        if (stderr && stderr.includes('Failed to')) {
          return this.createErrorResponse(
            `Failed to load sprite: ${stderr}`,
            [
              'Check if the node path is correct',
              'Ensure the node is a Sprite2D, Sprite3D, or TextureRect',
              'Verify the texture file is a valid image format',
            ]
          );
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Sprite loaded successfully with texture: ${args.texturePath}\n\nOutput: ${stdout}`,
            },
          ],
        };
      } catch (error: any) {
        return this.createErrorResponse(
          `Failed to load sprite: ${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 defining the parameters for the load_sprite tool: projectPath, scenePath, nodePath, texturePath.
      type: 'object',
      properties: {
        projectPath: {
          type: 'string',
          description: 'Path to the Godot project directory',
        },
        scenePath: {
          type: 'string',
          description: 'Path to the scene file (relative to project)',
        },
        nodePath: {
          type: 'string',
          description: 'Path to the Sprite2D node (e.g., "root/Player/Sprite2D")',
        },
        texturePath: {
          type: 'string',
          description: 'Path to the texture file (relative to project)',
        },
      },
      required: ['projectPath', 'scenePath', 'nodePath', 'texturePath'],
    },
  • src/index.ts:819-843 (registration)
    Registration of the load_sprite tool in the ListToolsRequestSchema response, including name, description, and input schema.
      name: 'load_sprite',
      description: 'Load a sprite into a Sprite2D node',
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: {
            type: 'string',
            description: 'Path to the Godot project directory',
          },
          scenePath: {
            type: 'string',
            description: 'Path to the scene file (relative to project)',
          },
          nodePath: {
            type: 'string',
            description: 'Path to the Sprite2D node (e.g., "root/Player/Sprite2D")',
          },
          texturePath: {
            type: 'string',
            description: 'Path to the texture file (relative to project)',
          },
        },
        required: ['projectPath', 'scenePath', 'nodePath', 'texturePath'],
      },
    },
  • src/index.ts:952-953 (registration)
    Dispatch registration in the CallToolRequestSchema handler switch statement, routing load_sprite calls to the handleLoadSprite method.
    case 'load_sprite':
      return await this.handleLoadSprite(request.params.arguments);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Load a sprite') but doesn't explain what this entails—e.g., whether it modifies the scene in memory, requires the editor to be running, or has side effects like saving changes. For a mutation tool with zero annotation coverage, this is a significant gap.

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 that directly states the tool's purpose without any fluff or redundancy. It's front-loaded and every word earns its place, making it easy for an agent to parse quickly.

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 the tool's complexity (involving multiple paths and likely scene modification), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, return values, or dependencies on other tools (e.g., 'launch_editor'). This leaves the agent with insufficient context for safe and effective use.

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 input schema has 100% description coverage, with clear parameter definitions (e.g., 'Path to the Godot project directory'). The description adds no additional meaning beyond the schema, such as explaining how paths interact or what happens if inputs are invalid. With high schema coverage, the baseline score of 3 is appropriate.

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 ('Load a sprite') and the target ('into a Sprite2D node'), which is specific and unambiguous. However, it doesn't differentiate this tool from potential siblings like 'add_node' or 'update_project_uids', which might also involve node manipulation, so it doesn't reach the highest score.

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. It doesn't mention prerequisites, such as needing an existing Sprite2D node, or compare it to siblings like 'add_node' for creating nodes or 'save_scene' for persisting changes. This leaves the agent without context for tool selection.

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

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