Skip to main content
Glama

edit_image

Modify existing images using AI by providing text instructions to add, remove, or alter elements. Upload an image and describe desired changes for automated editing.

Instructions

Modify an existing image using Google Gemini AI based on a text instruction. Provide the path to the image you want to edit and describe the changes that should be applied.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesDescribe the changes that should be applied to the provided image. Be specific about elements to add, remove, or modify.
imageYesPath to the image file that should be edited. Can be absolute or relative to the server.
outputPathNoOptional path where the edited image should be saved. If omitted, saves in the current working directory using an auto-generated filename.

Implementation Reference

  • The core handler function for the 'edit_image' tool. Validates input arguments, calls Gemini service to generate edited image data, saves it using image service, and returns the output file path.
    export async function handleEditImage(
      args: EditImageArgs,
      geminiService: GeminiService,
      imageService: ImageService
    ) {
      const description = args.description?.trim();
      if (!description) {
        throw invalidParams('Description is required to edit an image');
      }
    
      if (!args.image || !args.image.trim()) {
        throw invalidParams('Image path is required to edit an image');
      }
    
      try {
        const imageData = await geminiService.editImage({
          description,
          images: [args.image],
        });
    
        const filePath = await imageService.saveImage(imageData, {
          description,
          outputPath: args.outputPath,
        });
    
        return {
          content: [
            {
              type: 'text',
              text: filePath,
            },
          ],
        };
      } catch (error) {
        throw ensureMcpError(error, ErrorCode.InternalError, 'Failed to edit image', {
          stage: 'edit_image.tool',
        });
      }
    }
  • Type definition for the input arguments of the edit_image tool.
    export interface EditImageArgs {
      description: string;
      image: string;
      outputPath?: string;
    }
  • Tool definition including the input schema (JSON Schema) for the 'edit_image' tool.
    export const editImageTool: Tool = {
      name: 'edit_image',
      description:
        'Modify an existing image using Google Gemini AI based on a text instruction. Provide the path to the image you want to edit and describe the changes that should be applied.',
      inputSchema: {
        type: 'object',
        properties: {
          description: {
            type: 'string',
            description:
              'Describe the changes that should be applied to the provided image. Be specific about elements to add, remove, or modify.',
          },
          image: {
            type: 'string',
            description: 'Path to the image file that should be edited. Can be absolute or relative to the server.',
          },
          outputPath: {
            type: 'string',
            description:
              'Optional path where the edited image should be saved. If omitted, saves in the current working directory using an auto-generated filename.',
          },
        },
        required: ['description', 'image'],
      },
    };
  • src/index.ts:58-62 (registration)
    Registers the 'edit_image' tool (via editImageTool) in the MCP server's listTools response.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [generateImageTool, editImageTool],
      };
    });
  • src/index.ts:71-74 (registration)
    Dispatches calls to the 'edit_image' tool handler in the MCP server's callTool request handler.
    if (request.params.name === 'edit_image') {
      const args = request.params.arguments as unknown as EditImageArgs;
      return await handleEditImage(args, this.geminiService, this.imageService);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool modifies images using AI, implying mutation, but lacks details on permissions, side effects, rate limits, or output behavior. The mention of saving to an output path is covered in the schema, not behavioral context. This is inadequate 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 concise and front-loaded, with two sentences that directly state the tool's purpose and key parameters. Every sentence earns its place by providing essential information without redundancy or fluff.

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 (AI-based image editing with mutation), lack of annotations, and no output schema, the description is incomplete. It fails to address critical behavioral aspects like error handling, output format, or limitations, leaving significant gaps for an AI agent to understand the tool fully.

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 fully documents all three parameters. The description adds minimal value beyond the schema, mentioning the image path and description of changes but not elaborating on semantics. Baseline 3 is appropriate as the schema does the heavy lifting, though the description doesn't compensate for any gaps.

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 tool's purpose: 'Modify an existing image using Google Gemini AI based on a text instruction.' It specifies the verb ('Modify'), resource ('existing image'), and technology ('Google Gemini AI'), distinguishing it from the sibling tool 'generate_image' which likely creates new images. However, it doesn't explicitly contrast with the sibling beyond implied differences.

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 mentions the sibling tool 'generate_image' exists but gives no explicit comparison, prerequisites, or exclusions. Usage is implied through the description of modifying existing images, but no clear when/when-not rules are stated.

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/antoniolg/gemini-image-mcp-server'

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