Skip to main content
Glama

restore_image

Restore or enhance existing images using natural language prompts to describe the desired improvements.

Instructions

Restore or enhance an existing image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe text prompt describing the restoration to perform
fileYesThe filename of the input image to restore
previewNoAutomatically open generated images in default viewer

Implementation Reference

  • Handler logic for the 'restore_image' tool. Determines mode as 'restore' based on tool name, constructs ImageGenerationRequest with prompt, input image file, and other params, then delegates to ImageGenerator.editImage() for execution.
    case "edit_image":
    case "restore_image": {
      const mode = name === "edit_image" ? "edit" : "restore";
      const imageRequest: ImageGenerationRequest = {
        prompt: args?.prompt as string,
        inputImage: args?.file as string,
        mode,
        seed: args?.seed as number,
        preview: args?.preview as boolean,
        noPreview:
          (args?.noPreview as boolean) ||
          (args?.["no-preview"] as boolean),
      };
      response = await this.imageGenerator.editImage(imageRequest);
      break;
    }
  • Input schema and metadata for the 'restore_image' tool, defining required 'prompt' and 'file' parameters with descriptions.
    {
      name: "restore_image",
      description: "Restore or enhance an existing image",
      inputSchema: {
        type: "object",
        properties: {
          prompt: {
            type: "string",
            description:
              "The text prompt describing the restoration to perform",
          },
          file: {
            type: "string",
            description: "The filename of the input image to restore",
          },
          preview: {
            type: "boolean",
            description:
              "Automatically open generated images in default viewer",
            default: false,
          },
        },
        required: ["prompt", "file"],
      },
    },
  • Core implementation in ImageGenerator.editImage() that handles restoration (when mode='restore'). Loads input image as base64, sends to OpenRouter API via image-to-image endpoint with restoration prompt, saves output image, and handles preview.
    async editImage(
      request: ImageGenerationRequest
    ): Promise<ImageGenerationResponse> {
      try {
        if (!request.inputImage) {
          return {
            success: false,
            message: "Input image file is required for editing",
            error: "Missing inputImage parameter",
          };
        }
    
        const fileResult = FileHandler.findInputFile(request.inputImage);
        if (!fileResult.found) {
          return {
            success: false,
            message: `Input image not found: ${request.inputImage}`,
            error: `Searched in: ${fileResult.searchedPaths.join(", ")}`,
          };
        }
    
        const outputPath = FileHandler.ensureOutputDirectory();
        const imageBase64 = await FileHandler.readImageAsBase64(
          fileResult.filePath!
        );
        const fileName = path.basename(fileResult.filePath!);
        const mimeType = this.detectMimeType(fileName);
    
        const dataUrl = `data:${mimeType};base64,${imageBase64}`;
    
        const payload: Record<string, unknown> = {
          model: this.modelName,
          input: [
            {
              role: "user",
              content: [
                {
                  type: "input_text",
                  text: request.prompt,
                },
              ],
            },
          ],
          images: [dataUrl],
        };
    
        if (request.seed !== undefined) {
          payload.seed = request.seed;
        }
    
        const response = await this.postJson<OpenRouterImageResponse>(
          this.generationPath,
          payload
        );
    
        const imageBase64Result = this.parseImageFromResponse(response);
    
        if (!imageBase64Result) {
          return {
            success: false,
            message: `Failed to ${request.mode} image`,
            error: "No image data returned in OpenRouter response",
          };
        }
    
        const filename = FileHandler.generateFilename(
          `${request.mode}_${request.prompt}`,
          "png",
          0
        );
        const fullPath = await FileHandler.saveImageFromBase64(
          imageBase64Result,
          outputPath,
          filename
        );
    
        await this.handlePreview([fullPath], request);
    
        return {
          success: true,
          message: `Successfully ${request.mode}d image`,
          generatedFiles: [fullPath],
        };
      } catch (error: unknown) {
        logger.error(`Error in ${request.mode}Image:`, error);
        return {
          success: false,
          message: `Failed to ${request.mode} image`,
          error: this.handleApiError(error),
        };
      }
    }
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 mentions 'restore or enhance' but doesn't specify what that entails (e.g., quality improvement, content modification, or technical fixes), whether it's destructive, requires specific permissions, or has rate limits. This leaves significant gaps in understanding the tool's behavior.

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 unnecessary words. It is appropriately sized and front-loaded, 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 complexity of image restoration/enhancement, no annotations, and no output schema, the description is incomplete. It lacks details on what the tool returns (e.g., a modified image file, success status), behavioral traits, or usage context, making it inadequate for informed tool selection.

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%, so the schema already documents all three parameters (prompt, file, preview) with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as examples or context for how parameters interact, resulting in a baseline score of 3.

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 ('restore or enhance') and resource ('an existing image'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'edit_image' or 'generate_image', which might have overlapping functionality, 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 like 'edit_image' or 'generate_image'. There are no explicit when/when-not instructions or prerequisites mentioned, leaving the agent to infer usage from the tool name alone.

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/Aeven-AI/mcp-nanobanana'

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