Enables image generation from text prompts using Google's Gemini AI models (gemini-3-pro-image-preview and gemini-2.5-flash-image), with support for customizable aspect ratios, resolutions up to 4K, and automatic local image saving.
MCP Image Gen
A Model Context Protocol (MCP) server for generating images using Google's Gemini AI models.
Features
🎨 Generate high-quality images from text prompts using Gemini AI
📐 Customizable aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)
🔧 Configurable image sizes (small to 4K resolution)
⚙️ Flexible configuration via JSON file
💾 Automatic local image saving with organized filenames (saves to ~/gemini_images by default)
🚀 Built on the MCP SDK for seamless integration
⚠️ Known Issues
Aspect ratio and image size parameters may not be working correctly - Images are currently being generated in landscape format regardless of the specified aspect ratio. This is being investigated. The API calls appear correct, but the Gemini API may not be respecting the configuration parameters as expected.
Models Supported
gemini-3-pro-image-preview (Default): Professional-grade, supports up to 4K resolution
gemini-2.5-flash-image: Optimized for speed, generates 1024px resolution
Installation
Clone the repository:
Install dependencies:
Build the project:
Configuration
Environment Variables
Set your Gemini API key:
Get your API key from Google AI Studio.
Config File (Optional)
Create a config.json file in the project root to customize defaults:
Available Options:
model:"gemini-3-pro-image-preview"or"gemini-2.5-flash-image"defaultAspectRatio:"1:1","16:9","9:16","4:3", or"3:4"defaultImageSize:"small"(1K - 1024px)"medium"(2K - 2048px)"large"(2K - 2048px)"xlarge"(4K - 4096px - only for gemini-3-pro-image-preview)
outputDirectory: Path where generated images will be saved (default:~/gemini_images, can use absolute paths or~for home directory)
Usage with Claude Desktop
Add to your Claude Desktop configuration file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Tool: generate_image
Generate an image from a text prompt.
Parameters
prompt (required): Text description of the image to generate
aspectRatio (optional): Aspect ratio -
"1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"imageSize (optional): Resolution -
"small"(1K),"medium"(2K),"large"(2K),"xlarge"(4K)negativePrompt (optional): Describe what you DON'T want in the image
Example Usage in Claude
Response Format
The tool returns a JSON response with:
Image Quality Notes
All generated images include a SynthID watermark (Google's digital watermark)
gemini-3-pro-image-preview: Best for high-quality, detailed images up to 4K
gemini-2.5-flash-image: Best for quick generation, fixed at 1024px resolution
Development
Watch mode for development:
Build for production:
Troubleshooting
"GEMINI_API_KEY environment variable is required"
Make sure you've set the GEMINI_API_KEY environment variable or added it to your MCP configuration.
Images not generating
Check your API key is valid
Verify you have internet connectivity
Ensure the output directory is writable
Size options not working
The gemini-2.5-flash-image model only supports 1024px resolution regardless of the size parameter. Use gemini-3-pro-image-preview for higher resolutions.
License
MIT