Skip to main content
Glama

save_scene

Save modifications to a Godot scene file, optionally creating variants by specifying a new path.

Instructions

Save changes to a scene file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the Godot project directory
scenePathYesPath to the scene file (relative to project)
newPathNoOptional: New path to save the scene to (for creating variants)

Implementation Reference

  • The main handler function for the 'save_scene' tool. It validates the input parameters (projectPath, scenePath, optional newPath), checks project and scene validity, prepares parameters, executes the underlying Godot 'save_scene' operation via executeOperation, handles errors, and returns success or error response.
    private async handleSaveScene(args: any) {
      // Normalize parameters to camelCase
      args = this.normalizeParameters(args);
      
      if (!args.projectPath || !args.scenePath) {
        return this.createErrorResponse(
          'Missing required parameters',
          ['Provide projectPath and scenePath']
        );
      }
    
      if (!this.validatePath(args.projectPath) || !this.validatePath(args.scenePath)) {
        return this.createErrorResponse(
          'Invalid path',
          ['Provide valid paths without ".." or other potentially unsafe characters']
        );
      }
    
      // If newPath is provided, validate it
      if (args.newPath && !this.validatePath(args.newPath)) {
        return this.createErrorResponse(
          'Invalid new path',
          ['Provide a valid new path 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',
            ]
          );
        }
    
        // Prepare parameters for the operation (already in camelCase)
        const params: any = {
          scenePath: args.scenePath,
        };
    
        // Add optional parameters
        if (args.newPath) {
          params.newPath = args.newPath;
        }
    
        // Execute the operation
        const { stdout, stderr } = await this.executeOperation('save_scene', params, args.projectPath);
    
        if (stderr && stderr.includes('Failed to')) {
          return this.createErrorResponse(
            `Failed to save scene: ${stderr}`,
            [
              'Check if the scene file is valid',
              'Ensure you have write permissions to the output path',
              'Verify the scene can be properly packed',
            ]
          );
        }
    
        const savePath = args.newPath || args.scenePath;
        return {
          content: [
            {
              type: 'text',
              text: `Scene saved successfully to: ${savePath}\n\nOutput: ${stdout}`,
            },
          ],
        };
      } catch (error: any) {
        return this.createErrorResponse(
          `Failed to save scene: ${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',
          ]
        );
      }
    }
  • Defines the input schema and metadata for the 'save_scene' tool in the ListTools response, specifying required parameters projectPath and scenePath, and optional newPath.
      description: 'Save changes to a scene file',
      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)',
          },
          newPath: {
            type: 'string',
            description: 'Optional: New path to save the scene to (for creating variants)',
          },
        },
        required: ['projectPath', 'scenePath'],
      },
    },
  • src/index.ts:956-957 (registration)
    Registers the 'save_scene' tool handler in the switch statement for CallToolRequestSchema, dispatching to handleSaveScene.
    case 'save_scene':
      return await this.handleSaveScene(request.params.arguments);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
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 only states that the tool mutates/saves a scene file, not whether it overwrites the existing file, how newPath behaves beyond the schema's variant hint, or what happens on failure.

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?

One short sentence with no filler or redundant content; the core action is front-loaded. It is appropriately concise, even though it sacrifices detail that is captured in other dimensions.

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?

With no annotations and no output schema, the description should compensate but does not; it omits overwrite behavior, success/failure signaling, and any preconditions. The schema covers parameters, so the tool is not wholly underspecified, but the description alone is insufficient for confident invocation.

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?

Schema description coverage is 100%: projectPath and scenePath are described as paths, and newPath is explicitly documented as an optional path for creating variants. The description adds no additional parameter meaning, so the baseline 3 applies.

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 uses the specific verb 'save' with the resource 'scene file,' clearly indicating a persistence operation. It does not explicitly differentiate from create_scene, though 'save changes' implies an existing scene, so it stops short of full sibling distinction.

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?

No guidance is given on when to use this tool versus create_scene or other scene tools, and no prerequisites or exclusions are provided. The word 'changes' implies use after modifications, but that is not actionable enough to help an agent choose correctly.

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