Skip to main content
Glama
georgejeffers

Gemini MCP Server

Edit Image

edit_image
Read-only

Modify images by describing changes in text. Upload an encoded image and specify edits to transform visual content according to your instructions.

Instructions

Edit an image using a text prompt. Send a base64-encoded image and describe the desired changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of the edits to apply
imageYesBase64-encoded source image
mimeTypeNoMIME type of the source imageimage/png
modelNoImage model to use (Nano Banana Pro by default)gemini-3-pro-image-preview
aspectRatioNoAspect ratio of the output image1:1
imageSizeNoOutput image resolution1K

Implementation Reference

  • Main implementation of the edit_image tool. Contains the register function with tool metadata, input schema definition (lines 14-21), and the async handler function (lines 28-63) that processes image editing requests using Google's GenAI API.
    export function register(server: McpServer, ai: GoogleGenAI): void {
      server.registerTool(
        'edit_image',
        {
          title: 'Edit Image',
          description: 'Edit an image using a text prompt. Send a base64-encoded image and describe the desired changes.',
          inputSchema: {
            prompt: z.string().min(1).describe('Description of the edits to apply'),
            image: z.string().min(1).describe('Base64-encoded source image'),
            mimeType: z.enum(['image/png', 'image/jpeg', 'image/webp']).default('image/png').describe('MIME type of the source image'),
            model: ImageModel.default('gemini-3-pro-image-preview').describe('Image model to use (Nano Banana Pro by default)'),
            aspectRatio: AspectRatio.default('1:1').describe('Aspect ratio of the output image'),
            imageSize: ImageSize.default('1K').describe('Output image resolution'),
          },
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            openWorldHint: true,
          },
        },
        async ({ prompt, image, mimeType, model, aspectRatio, imageSize }) => {
          try {
            const response = await ai.models.generateContent({
              model,
              contents: [
                { text: prompt },
                { inlineData: { mimeType, data: image } },
              ],
              config: {
                responseModalities: ['TEXT', 'IMAGE'],
                imageConfig: { aspectRatio, imageSize },
              },
            });
    
            const result = extractImageFromResponse(response);
            if (!result) {
              return {
                content: [{ type: 'text' as const, text: 'No edited image was produced. Try a different prompt.' }],
                isError: true,
              };
            }
    
            if (!validateImageSize(result.data)) {
              return {
                content: [{ type: 'text' as const, text: 'Edited image exceeds size limit. Try a smaller imageSize.' }],
                isError: true,
              };
            }
    
            return {
              content: [{ type: 'image' as const, data: result.data, mimeType: result.mimeType }],
            };
          } catch (error) {
            return formatToolError(error);
          }
        },
      );
  • Input schema definition for edit_image tool. Defines prompt, image, mimeType, model, aspectRatio, and imageSize parameters with Zod validation.
    inputSchema: {
      prompt: z.string().min(1).describe('Description of the edits to apply'),
      image: z.string().min(1).describe('Base64-encoded source image'),
      mimeType: z.enum(['image/png', 'image/jpeg', 'image/webp']).default('image/png').describe('MIME type of the source image'),
      model: ImageModel.default('gemini-3-pro-image-preview').describe('Image model to use (Nano Banana Pro by default)'),
      aspectRatio: AspectRatio.default('1:1').describe('Aspect ratio of the output image'),
      imageSize: ImageSize.default('1K').describe('Output image resolution'),
    },
  • src/index.ts:9-9 (registration)
    Import statement for the edit_image tool registration functions.
    import { register as registerEditImage, registerMulti as registerEditImageMulti } from './tools/edit-image.js';
  • src/index.ts:30-31 (registration)
    Registration of both edit_image and edit_image_multi tools with the MCP server.
    registerEditImage(server, ai);
    registerEditImageMulti(server, ai);
  • Helper function extractImageFromResponse that extracts the base64 image data and MIME type from the GenAI API response.
    export function extractImageFromResponse(response: any): { data: string; mimeType: string } | null {
      const parts = response?.candidates?.[0]?.content?.parts;
      if (!parts) return null;
      for (const part of parts) {
        if (part.inlineData) {
          return {
            data: part.inlineData.data,
            mimeType: part.inlineData.mimeType,
          };
        }
      }
      return null;
    }
Behavior3/5

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

Annotations indicate read-only, open-world, and non-destructive operations, which the description doesn't contradict. The description adds context about the editing process ('using a text prompt') and input requirements, but doesn't disclose behavioral traits like rate limits, authentication needs, or output format details beyond what annotations provide.

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 front-loads the core purpose ('Edit an image using a text prompt') and specifies key inputs without unnecessary details. Every word earns its place, making it easy to parse quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (6 parameters, image editing functionality) and lack of an output schema, the description is minimally adequate. It covers the basic operation but doesn't address output format (e.g., returned image type), error conditions, or advanced usage scenarios, leaving gaps for an AI agent to infer.

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?

With 100% schema description coverage, the schema fully documents all 6 parameters. The description mentions 'base64-encoded image' and 'text prompt', aligning with the 'image' and 'prompt' parameters, but adds no additional semantic meaning beyond what's in the schema (e.g., how prompts are interpreted or image processing details).

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 ('Edit an image') and the mechanism ('using a text prompt'), specifying the required inputs (base64-encoded image and description). It distinguishes from sibling tools like 'generate_image' (creation vs. editing) but doesn't explicitly differentiate from 'edit_image_multi' beyond the single-image focus implied by the parameters.

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

Usage Guidelines3/5

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

The description implies usage for editing existing images with text prompts, contrasting with 'generate_image' for creation from scratch. However, it lacks explicit guidance on when to choose this over 'edit_image_multi' (e.g., for single vs. multiple images) or other alternatives, and doesn't mention prerequisites like image format compatibility.

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

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