Gemini Flash Image MCP Server
Provides image generation and editing capabilities using Google's Gemini 2.5 Flash Image API, including text-to-image generation, image editing with natural language instructions, multi-image composition, and support for various aspect ratios
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gemini Flash Image MCP Servercreate a logo for my coffee shop called 'Morning Brew'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Gemini Flash Image 2.5 Tool (Nano Banana)
A tool for generating and editing images using Google's Gemini 2.5 Flash Image API (affectionately known as "Nano Banana").
Includes both a Python CLI tool and a Model Context Protocol (MCP) server for integration with AI assistants like Claude Code.
Features
Text-to-Image Generation: Create images from text prompts
Image Editing: Modify existing images with natural language instructions
Multi-Image Composition: Combine multiple images into one
Flexible Aspect Ratios: Support for 10 different aspect ratios
Character Consistency: Maintain character appearance across multiple generations
MCP Server: Integrate with Claude Code and other MCP clients
Command-Line Interface: Easy-to-use CLI for quick operations
Python API: Use as a library in your own projects
Related MCP server: OpenRouter Image MCP Server
Installation
Option 1: MCP Server (Recommended for AI Assistants)
Simplest Install (using npx)
For Claude Code MCP configuration, you can reference the package directly via GitHub:
Add to your MCP settings (~/.config/claude/claude_desktop_config.json):
{
"mcpServers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "github:brunoqgalvao/gemini-image-mcp-server"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}Then restart Claude Code! The generate_image tool will be available instantly.
Local Install
# Clone the repository
git clone https://github.com/brunoqgalvao/gemini-image-mcp-server.git
cd gemini-image-mcp-server
# Run the installer
./install.shThe installer will:
Install Node.js dependencies
Create a
.envfile from templateRun validation tests
Show you the MCP configuration to add to Claude Code
Manual Install
Clone or download this repository
Install Node.js dependencies:
npm installGet your API key from Google AI Studio
Create a
.envfile in the project directory:
GEMINI_API_KEY=your_api_key_hereConfigure your MCP client (e.g., Claude Code):
For macOS/Linux - Add to ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["/absolute/path/to/agent-dispatcher/index.js"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}For Windows - Add to %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["C:\\absolute\\path\\to\\agent-dispatcher\\index.js"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}Restart Claude Code or your MCP client
Installing on Another Computer
Easiest way - Just use npx! On any computer with Node.js:
Add to Claude Code MCP settings:
{
"mcpServers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "github:brunoqgalvao/gemini-image-mcp-server"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}No cloning needed! npx will fetch and run it automatically.
Alternative: Local installation
# Clone and install
git clone https://github.com/brunoqgalvao/gemini-image-mcp-server.git
cd gemini-image-mcp-server
./install.shOption 2: Python CLI Tool
Clone or download this repository
Install Python dependencies:
pip install -r requirements.txtGet your API key from Google AI Studio
Create a
.envfile in the project directory:
GEMINI_API_KEY=your_api_key_hereUsage
MCP Server
Once configured, the generate_image tool will be available in your MCP client:
Parameters:
prompt(required): Text description of the image to generate or edits to makeoutput_path(required): Path where the image will be saved (must end in .png)input_images(optional): Array of paths to input images for editing/compositionaspect_ratio(optional): One of: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9image_only(optional): Set to true for image-only output without text
Example usage in Claude Code:
"Generate a sunset over mountains and save it to sunset.png"The MCP server will handle the API call and save the image automatically.
Command Line
Basic text-to-image generation:
python gemini_image_tool.py "A cat eating a banana in space" -o cat_banana.pngEdit an existing image:
python gemini_image_tool.py "Remove the background" -i photo.jpg -o edited.pngCompose multiple images:
python gemini_image_tool.py "Combine these into a collage" -i img1.jpg -i img2.jpg -o collage.pngSpecify aspect ratio:
python gemini_image_tool.py "A cinematic landscape" -o wide.png --aspect-ratio 21:9Image-only output (no text response):
python gemini_image_tool.py "A red apple" -o apple.png --image-onlySave full API response:
python gemini_image_tool.py "A sunset" -o sunset.png --save-json response.jsonPython API
from gemini_image_tool import GeminiImageTool
# Initialize the tool
tool = GeminiImageTool(api_key="your_api_key_here")
# Generate an image
result = tool.generate_content(
prompt="A futuristic city at night",
aspect_ratio="16:9",
output_path="city.png"
)
# Edit an image
result = tool.generate_content(
prompt="Make the sky purple",
input_images=["city.png"],
output_path="city_purple.png"
)
# Combine multiple images
result = tool.generate_content(
prompt="Create a before/after comparison",
input_images=["before.jpg", "after.jpg"],
aspect_ratio="2:1",
output_path="comparison.png"
)Available Aspect Ratios
1:1- Square (default)2:3- Portrait3:2- Landscape3:4- Portrait4:3- Landscape4:5- Portrait5:4- Landscape9:16- Vertical (social media)16:9- Widescreen21:9- Cinematic
Supported Image Formats
Input: JPG, JPEG, PNG, WebP, GIF Output: PNG
Pricing
As of 2025, Gemini 2.5 Flash Image is priced at:
$30.00 per 1 million output tokens
Each image = 1290 output tokens
Cost per image: ~$0.039
Use Cases
E-commerce: Product photography and variations
Content Creation: Social media graphics, blog images
Marketing: Ad creatives, promotional materials
Storytelling: Consistent character illustrations
Photo Editing: Background removal, color correction, object removal
Design: Logo variations, mockups, concept art
Command-Line Arguments
positional arguments:
prompt Text prompt for image generation/editing
optional arguments:
-h, --help Show help message
-i INPUT, --input INPUT
Input image file path (can be specified multiple times)
-o OUTPUT, --output OUTPUT
Output image file path (default: output.png)
-a ASPECT_RATIO, --aspect-ratio ASPECT_RATIO
Output aspect ratio (default: 1:1)
--image-only Request image-only output (no text response)
--api-key API_KEY Google AI API key (or set GEMINI_API_KEY env variable)
--save-json SAVE_JSON
Save full API response to JSON fileError Handling
The tool includes comprehensive error handling for:
Missing API keys
Invalid image paths
Unsupported image formats
Invalid aspect ratios
API request failures
Network errors
Notes
All generated images include a SynthID watermark (added by Google)
The model benefits from Gemini's world knowledge for enhanced generation
Character consistency works best with clear, descriptive prompts
For best results, be specific in your prompts
Documentation
For more information about Gemini 2.5 Flash Image:
License
This tool is provided as-is for use with the Gemini API. See Google's terms of service for API usage restrictions.
Available Tools
1 toolgenerate_imageA
Generate or edit images using Gemini 2.5 Flash Image (Nano Banana). Supports text-to-image generation, image editing with natural language prompts, and multi-image composition. All generated images include a SynthID watermark.
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Text prompt describing the image to generate or edits to make | |
| input_images | No | Optional array of file paths to input images for editing or composition | |
| aspect_ratio | No | Output aspect ratio. Options: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 | 1:1 |
| output_path | Yes | Path where the generated image will be saved (must end in .png) | output.png |
| image_only | No | If true, requests image-only output without text response |
TDQS
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 effectively describes key traits: the tool can generate or edit images, supports multiple input types (text prompts, input images), and includes a SynthID watermark on outputs. However, it lacks details on rate limits, error conditions, or performance characteristics, leaving some behavioral aspects unspecified.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose in the first sentence, followed by specific capabilities and a critical behavioral note (watermark). It uses two concise sentences with no redundant or extraneous information, making it highly efficient and well-structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (image generation/editing with 5 parameters) and lack of annotations or output schema, the description provides a solid foundation by covering purpose, capabilities, and key behavior (watermark). However, it does not address output format details (e.g., image resolution, file size) or error handling, which could enhance completeness for an AI agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, providing clear documentation for all parameters. The description adds minimal semantic value beyond the schema, as it mentions 'text prompts' and 'input images' but does not elaborate on parameter interactions or usage nuances. The baseline score of 3 is appropriate given the comprehensive schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('generate or edit images') and resource ('images'), identifies the underlying technology ('Gemini 2.5 Flash Image (Nano Banana)'), and lists three distinct capabilities: text-to-image generation, image editing with natural language prompts, and multi-image composition. This is comprehensive and unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage contexts by listing capabilities (e.g., use for text-to-image, editing, or composition) but does not provide explicit guidance on when to choose this tool over alternatives or any prerequisites. Since there are no sibling tools, the lack of differentiation is not penalized, but it remains at an implied level without exclusions or best practices.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
- First observed
generate_image
TDQS
Scored across 1 tool
With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool 'generate_image' has a clear, distinct purpose focused on image generation and editing.
A single tool inherently has perfect naming consistency, as there are no other tools to compare it against. The name 'generate_image' follows a clear verb_noun pattern and is descriptive.
One tool is too few for a server with a broad purpose like image generation and editing. The description suggests capabilities for text-to-image, editing, and composition, which could reasonably be split into multiple specialized tools (e.g., generate, edit, compose) for better agent usability and clarity.
The single tool covers core functionalities (generation, editing, composition), but the surface feels thin. There are no tools for related operations like listing generated images, deleting images, or managing settings, which could limit agent workflows. However, the main purpose is addressed.
Maintenance
Related MCP Connectors
Create images and videos from prompts, with options for image mixing, reference images, and start/…
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
AI image generation across 5 quality tiers (SDXL to Gemini 3 Pro), 50 free credits on signup.
Generate and edit images and videos with imageat.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables conversational image generation and editing with Google's Gemini 2.5 Flash Image Preview. Supports text-to-image generation, natural language image editing, multi-image composition, and style transfer with optional file saving.49 npm3MIT
- -licenseAqualityNot gradedmaintenanceEnables generating and editing images using OpenRouter's API with Gemini 2.5 Flash Image model. Supports custom aspect ratios, iterative editing, and reference images for style transfer.623 npm-
- AlicenseNot gradedqualityDmaintenanceEnables generating, editing, and manipulating images using Google Gemini Flash 2.5 through natural language prompts. Supports text-to-image generation, image editing, multi-image composition, and batch processing with direct file management.42 npm4MIT
- FlicenseNot gradedqualityCmaintenanceEnables image generation and editing using Google's Gemini models with support for model selection and custom aspect ratios. Users can generate high-quality images or modify existing ones through natural language prompts while controlling specific parameters like quality and dimensions.-