Image Generator
STDIOMCP server for AI image generation and editing using Google Gemini API
MCP server for AI image generation and editing using Google Gemini API
Powered by Gemini 2.5 Flash Image - Nano Banana 🍌
A powerful MCP (Model Context Protocol) server that enables AI assistants to generate and edit images using Google's Gemini 2.5 Flash Image (Nano Banana 🍌). Seamlessly integrate advanced image generation capabilities into Codex, Cursor, Claude Code, and other MCP-compatible AI tools.
Get your API key from Google AI Studio
Add to ~/.codex/config.toml:
[mcp_servers.mcp-image] command = "npx" args = ["-y", "mcp-image"] [mcp_servers.mcp-image.env] GEMINI_API_KEY = "your_gemini_api_key_here" IMAGE_OUTPUT_DIR = "/absolute/path/to/images"
Add to your Cursor settings:
~/.cursor/mcp.json.cursor/mcp.json in your project root{ "mcpServers": { "mcp-image": { "command": "npx", "args": ["-y", "mcp-image"], "env": { "GEMINI_API_KEY": "your_gemini_api_key_here", "IMAGE_OUTPUT_DIR": "/absolute/path/to/images" } } } }
Run in your project directory to enable for that project:
cd /path/to/your/project claude mcp add mcp-image --env GEMINI_API_KEY=your-api-key --env IMAGE_OUTPUT_DIR=/absolute/path/to/images -- npx -y mcp-image
Or add globally for all projects:
claude mcp add mcp-image --scope user --env GEMINI_API_KEY=your-api-key --env IMAGE_OUTPUT_DIR=/absolute/path/to/images -- npx -y mcp-image
⚠️ Security Note: Never commit your API key to version control. Keep it secure and use environment-specific configuration.
📁 Path Requirements:
IMAGE_OUTPUT_DIR must be an absolute path (e.g., /Users/username/images, not ./images)./output in the current working directory if not specifiedSet SKIP_PROMPT_ENHANCEMENT=true to disable automatic prompt optimization and send your prompts directly to the image generator. Useful when you need full control over the exact prompt wording.
Codex:
[mcp_servers.mcp-image.env] GEMINI_API_KEY = "your_gemini_api_key_here" SKIP_PROMPT_ENHANCEMENT = "true" IMAGE_OUTPUT_DIR = "/absolute/path/to/images"
Cursor:
Add "SKIP_PROMPT_ENHANCEMENT": "true" to the env section in your config.
Claude Code:
claude mcp add mcp-image --env GEMINI_API_KEY=your-api-key --env SKIP_PROMPT_ENHANCEMENT=true --env IMAGE_OUTPUT_DIR=/absolute/path/to/images -- npx -y mcp-image
Once configured, your AI assistant can generate images using natural language:
"Generate a serene mountain landscape at sunset with a lake reflection"
The system automatically enhances this to include rich details about lighting, materials, composition, and atmosphere for optimal results.
"Edit this image to make the person face right"
(with inputImagePath: "/path/to/image.jpg")
"Generate a portrait of a medieval knight, maintaining character consistency for future variations"
(with maintainCharacterConsistency: true)
generate_image ToolThe MCP server exposes a single tool for all image operations. Internally, it uses a two-stage process:
| Parameter | Type | Required | Description | 
|---|---|---|---|
prompt | string | ✅ | Text description or editing instruction | 
inputImagePath | string | - | Absolute path to input image for editing | 
fileName | string | - | Custom filename for output (auto-generated if not specified) | 
aspectRatio | string | - | Aspect ratio for the generated image. Supported values: 1:1 (square, default), 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 | 
blendImages | boolean | - | Enable multi-image blending | 
maintainCharacterConsistency | boolean | - | Maintain character appearance across generations | 
useWorldKnowledge | boolean | - | Use real-world knowledge for context | 
{ "type": "resource", "resource": { "uri": "file:///path/to/generated/image.png", "name": "image-filename.png", "mimeType": "image/png" }, "metadata": { "model": "gemini-2.5-flash-image", "processingTime": 5000, "timestamp": "2024-01-01T12:00:00.000Z" } }
"API key not found"
GEMINI_API_KEY is set in your environment"Input image file not found"
"No image data found in Gemini API response"
useWorldKnowledge for historical or factual subjectsMIT License - see LICENSE for details.
Need help? Open an issue or check the troubleshooting section above.