Skip to main content
Glama
Yoon-jongho

Claude-to-Gemini MCP Server

by Yoon-jongho

generate_image_gemini

Generate images from text descriptions using Google's Gemini AI for contextual understanding, editing, composition, and iterative refinement.

Instructions

Generate images using Gemini 2.5 Flash Image (Nano Banana). Best for contextual understanding, image editing, multi-image composition, and iterative refinement. Free tier available.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of the image to generate (in English, max 480 tokens)
numberOfImagesNoNumber of images to generate (1-4, default: 1)

Implementation Reference

  • The handler function for the 'generate_image_gemini' tool. It uses the Gemini 2.5 Flash Image model to generate images based on the provided prompt, handles multiple images, saves them to 'generated_images' directory, and returns text summary with image data.
    if (name === "generate_image_gemini") {
      const { prompt, numberOfImages = 1 } = args;
    
      const model = genAI.getGenerativeModel({
        model: "gemini-2.5-flash-image",
      });
    
      const result = await model.generateContent({
        contents: [{ role: "user", parts: [{ text: prompt }] }],
        generationConfig: {
          responseModalities: ["image"],
        },
      });
    
      const response = await result.response;
      const images = response.candidates?.[0]?.content?.parts?.filter(
        (part) => part.inlineData
      );
    
      if (!images || images.length === 0) {
        throw new Error("No images were generated");
      }
    
      // 이미지 저장
      const outputDir = join(__dirname, "generated_images");
      await mkdir(outputDir, { recursive: true });
    
      const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
      const savedPaths = [];
    
      for (let i = 0; i < images.length; i++) {
        const img = images[i];
        const ext = img.inlineData.mimeType.split("/")[1] || "png";
        const filename = `gemini_${timestamp}_${i + 1}.${ext}`;
        const filepath = join(outputDir, filename);
    
        const buffer = Buffer.from(img.inlineData.data, "base64");
        await writeFile(filepath, buffer);
        savedPaths.push(filepath);
      }
    
      return {
        content: [
          {
            type: "text",
            text: `[Gemini 2.5 Flash Image (Nano Banana)]\n\nGenerated ${images.length} image(s) for: "${prompt}"\n\nSaved to:\n${savedPaths.map(p => `- ${p}`).join("\n")}`,
          },
          ...images.map((img) => ({
            type: "image",
            data: img.inlineData.data,
            mimeType: img.inlineData.mimeType,
          })),
        ],
      };
    }
    
    if (name === "generate_image_imagen") {
  • index.js:95-118 (registration)
    Registration of the 'generate_image_gemini' tool in the ListTools response, defining its name, description, and input schema.
    {
      name: "generate_image_gemini",
      description:
        "Generate images using Gemini 2.5 Flash Image (Nano Banana). Best for contextual understanding, image editing, multi-image composition, and iterative refinement. Free tier available.",
      inputSchema: {
        type: "object",
        properties: {
          prompt: {
            type: "string",
            description:
              "Description of the image to generate (in English, max 480 tokens)",
          },
          numberOfImages: {
            type: "number",
            description:
              "Number of images to generate (1-4, default: 1)",
            default: 1,
            minimum: 1,
            maximum: 4,
          },
        },
        required: ["prompt"],
      },
    },
Behavior3/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 the model name ('Gemini 2.5 Flash Image (Nano Banana)') and use cases, but doesn't disclose important behavioral traits like rate limits, authentication needs, cost implications beyond 'Free tier available', or what happens on failure. The free tier mention is useful but insufficient for full transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that each serve a purpose: the first states the core function and model, the second provides usage context and cost information. It's front-loaded with the main purpose. However, the parenthetical model name '(Nano Banana)' adds minor clutter without clear value.

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 2 parameters with 100% schema coverage but no annotations and no output schema, the description is moderately complete. It covers the what and some when, but lacks important context about behavioral constraints, error handling, and output format. For an image generation tool with potential cost/rate implications, more completeness would be helpful.

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 both parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it doesn't explain prompt best practices, token limitations beyond the schema's 'max 480 tokens', or how 'numberOfImages' affects output. Baseline 3 is appropriate when the schema does the heavy lifting.

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 generates images using a specific AI model (Gemini 2.5 Flash Image), which is a specific verb+resource combination. It distinguishes from sibling tools like 'ask_gemini' and 'gemini_analyze_codebase' by focusing on image generation rather than text analysis or code review. However, it doesn't explicitly differentiate from 'generate_image_imagen', which appears to be a similar image generation tool.

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 provides some context about when to use this tool ('Best for contextual understanding, image editing, multi-image composition, and iterative refinement'), which implies usage scenarios. However, it doesn't explicitly state when NOT to use it or mention alternatives like the sibling 'generate_image_imagen' tool, leaving the agent to infer the best choice between similar tools.

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/Yoon-jongho/claude-to-gemini'

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