Gemini Image Gen MCP Server
This server enables AI-powered image generation, editing, and upscaling using Google Gemini and Imagen models through a unified MCP interface.
Generate images from text prompts using models like
gemini-3.1-flash-image(default),gemini-3-pro-image, andgemini-2.5-flash-image.Edit images (Vertex AI only) — inpainting, outpainting, background swap, and other edits via mask or text instructions.
Upscale images (Vertex AI only) — super-resolution at 2x or 4x using Imagen models.
Dual provider support — free AI Studio or pay-per-use Vertex AI.
Dynamic model switching per request, with smart error recovery suggesting alternatives on quota issues.
Auto-save generated images to a configurable local directory with timestamps.
Built-in guides (via MCP Resources) for model selection and provider setup.
SOCKS proxy support for networks behind firewalls.
Provides AI image generation, editing (inpainting/outpainting), and upscaling through Google Gemini and Imagen models, with support for both AI Studio (free) and Vertex AI (GCP) providers.
Click on "Install 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 Image Gen MCP ServerGenerate an image of a serene lake at sunset."
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 Image Gen MCP Server
Features
3 tools —
generate_image,edit_image(inpainting/outpainting),upscale_image(2x/4x)Dual provider — AI Studio (free) or Vertex AI (GCP credits)
Multi-model — Gemini 3.1 / 3 Pro Image, Gemini 2.5 Flash Image, and legacy Imagen 4 on Vertex AI
Dynamic model switching — choose model per request via
modelparameter, no restart neededBuilt-in guides — MCP Resources with model selection tips and provider docs
Smart error recovery — auto-suggests alternative models on quota errors
Auto-save generated images to disk
SOCKS proxy support out of the box
Related MCP server: Gemini Image MCP
Demo
Architecture
User Prompt → AI Assistant (Claude / Cursor) → MCP Server → Gemini API / Vertex AI
↓
Save to disk + DisplayHow It Works
The server handles two distinct Google APIs under one unified interface:
API | Models | Endpoint | Request Format |
Predict API |
| Vertex AI only |
|
GenerateContent API |
| AI Studio + Vertex AI |
|
Capability API |
| Vertex AI only |
|
Upscale API |
| Vertex AI only |
|
The server automatically selects the correct API based on the model name prefix — imagen* routes to Predict, everything else to GenerateContent. You don't need to worry about this distinction.
Quick Start
Option A: AI Studio (Free, Recommended for Getting Started)
1. Get API Key — visit https://aistudio.google.com/apikey → Create API Key → copy it
2. Configure MCP
claude mcp add --transport stdio mcp-image \
--env GEMINI_API_KEY=your_api_key \
-- uv --directory /path/to/mcp-image-gen run image-gen{
"mcpServers": {
"mcp-image": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-image-gen", "run", "image-gen"],
"env": {
"GEMINI_API_KEY": "your_api_key"
}
}
}
}3. Use it — just ask your AI assistant:
"Generate an image of a dragon flying over mountains at dawn"The image will be displayed inline and automatically saved to the output/ directory.
Option B: Vertex AI (Higher Quality, GCP Credits)
Use GCP billing with Gemini image models, optional legacy Imagen 4 generation, plus image editing and upscaling.
1. Prerequisites
A GCP project with billing enabled (create one)
Vertex AI API enabled (enable it)
A GCP API key (create one)
2. Install with Vertex AI support
git clone https://github.com/kevinten-ai/mcp-image-gen.git
cd mcp-image-gen
uv sync --extra vertex3. Configure MCP
claude mcp add --transport stdio mcp-image \
--env GEMINI_PROVIDER=vertex-ai \
--env GEMINI_API_KEY=your_gcp_api_key \
--env GCP_PROJECT_ID=your-project-id \
--env GCP_REGION=us-central1 \
--env GEMINI_MODEL=gemini-3.1-flash-image \
-- uv --directory /path/to/mcp-image-gen run --extra vertex image-gen{
"mcpServers": {
"mcp-image": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-image-gen", "run", "--extra", "vertex", "image-gen"],
"env": {
"GEMINI_PROVIDER": "vertex-ai",
"GEMINI_API_KEY": "your_gcp_api_key",
"GCP_PROJECT_ID": "your-project-id",
"GCP_REGION": "us-central1",
"GEMINI_MODEL": "gemini-3.1-flash-image"
}
}
}
}Auth options: Vertex AI supports two authentication methods:
GCP API Key (recommended) — set
GEMINI_API_KEY. Simple, no extra deps.OAuth2 / ADC — run
gcloud auth application-default login. The server auto-detects ADC when no API key is set. Requires--extra vertexforgoogle-authdependency.
Tools
generate_image — Text to Image
Generate images from text prompts.
"A cozy cafe in Paris at sunset"edit_image — Image Editing (Vertex AI only)
Edit existing images with text instructions. Supports inpainting, outpainting, and background swap.
edit_image(prompt="Add a red hat", image_path="/path/to/photo.png")
edit_image(prompt="Replace background with beach", image_path="photo.png", edit_mode="product-image")
edit_image(prompt="Expand the sky", image_path="photo.png", mask_path="mask.png", edit_mode="outpainting")upscale_image — Super Resolution (Vertex AI only)
Upscale images to 2x or 4x resolution.
upscale_image(image_path="/path/to/photo.png", upscale_factor="x4")Usage Guide
Tips for Better Results
Be specific: "A golden retriever puppy playing in autumn leaves, soft natural lighting" works better than "a dog"
Mention style: Add terms like "digital art", "photorealistic", "watercolor", "oil painting", "anime style"
Describe lighting: "golden hour", "dramatic lighting", "soft diffused light"
Specify composition: "close-up portrait", "wide-angle landscape", "bird's eye view"
No text: Image models generally struggle with rendering text. Use "No text" in prompts for cleaner results.
Choosing a Model
Per-request switching (recommended)
Pass the model parameter when calling the tool:
generate_image(prompt="a sunset landscape", model="gemini-3-pro-image")AI assistants can dynamically pick the best model per request. If one model hits a quota limit, the error response automatically suggests an alternative.
Decision flowchart
Need an image?
├─ Free / no GCP account?
│ └─ AI Studio: gemini-3.1-flash-image ✅
│
└─ Have GCP billing?
├─ Need balanced quality/speed?
│ └─ gemini-3.1-flash-image ✅
│
├─ Need stronger reasoning/composition?
│ └─ gemini-3-pro-image
│
├─ Need to edit an image?
│ └─ edit_image tool (uses imagen-3.0-capability-001)
│
├─ Need to upscale?
│ └─ upscale_image tool (uses imagen-4.0-upscale-preview)
│
└─ Hit quota on one model?
└─ Switch to another — each model has independent quotaDefault via environment variable
Set GEMINI_MODEL to configure the default model used when no model parameter is passed:
# AI Studio (Gemini models)
GEMINI_MODEL=gemini-3.1-flash-image # default, balanced
GEMINI_MODEL=gemini-3-pro-image # stronger reasoning/composition
GEMINI_MODEL=gemini-2.5-flash-image # fallback
# Vertex AI (Gemini + legacy Imagen models)
GEMINI_MODEL=gemini-3.1-flash-image # default
GEMINI_MODEL=imagen-4.0-generate-001 # legacy Imagen; retires Aug 17, 2026MCP Resources
The server exposes built-in documentation that AI assistants can automatically read:
Resource URI | Description |
| Model comparison, pricing, quota tips, and selection guide |
| Provider setup, authentication, and troubleshooting |
AI assistants (Claude, etc.) can read these resources to make informed model choices without human intervention.
Custom Output Directory
--env IMAGE_OUTPUT_DIR=/absolute/path/to/your/imagesImages are saved with timestamps: imagen_20260321_234225.png or gemini_20260321_234225.png.
Environment Variables
Variable | Required | Default | Description |
| No |
|
|
| Yes* | — | API key (AI Studio or GCP). *Not required if using ADC. |
| No |
| Default model (can be overridden per request via |
| No |
| Directory to save generated images |
| Vertex AI only | — | GCP project ID |
| No |
| GCP region for Vertex AI |
Supported Models
AI Studio (Gemini) — Free
Model ID | Quality | Speed | Pricing | Best for |
| Highest | Fast | Free | Recommended default |
| Highest | Slower | Free | Reasoning-enhanced composition |
| Good | Fast | Free | Fallback |
Vertex AI (Imagen) — GCP Credits
Model ID | Quality | Speed | Pricing | Best for |
| Highest | Fast | Pay-per-use | Recommended default |
| Highest | Slower | Pay-per-use | Reasoning-enhanced composition |
| Good | Fast | Pay-per-use | Fallback |
| High | Fast | ~$0.04/image | Legacy Imagen; retires Aug 17, 2026 |
| Highest | Slower | ~$0.06/image | Legacy Imagen; retires Aug 17, 2026 |
| High | Fastest | ~$0.02/image | Legacy Imagen; retires Aug 17, 2026 |
Vertex AI — Specialized Models
Model ID | Tool | Pricing | Notes |
|
| ~$0.04/edit | Inpainting, outpainting, bg swap |
|
| Preview | 2x/4x super resolution |
Key insight: Each model has its own independent API quota. If one model hits a 429, switching to another will work because they use separate rate limits.
Troubleshooting
Error Reference
Error | Root Cause | Solution |
| Missing API key in env config | Set |
| Using Vertex AI without project ID | Set |
Quota & Billing Errors (429)
These are the most common errors. There are two distinct 429 errors with different causes:
429: Quota exceeded for online_prediction_requests_per_base_model
What it means: You've hit the per-minute API call rate limit for a specific model.
Quick fix: Switch to a different model via the model parameter — each model has independent quota:
generate_image(prompt="...", model="gemini-3-pro-image")Long-term fix: Request a quota increase:
Filter by
online_prediction_requests_per_base_modelFind your model (e.g.,
gemini-3.1-flash-imageorimagen-4.0-generate)Click Edit Quotas → request a higher limit (default is often just 5 QPM)
429: Quota exceeded ... spending cap
What it means: You've hit a self-imposed billing spending limit, NOT an API rate limit.
Fix:
Find the budget with a spending cap
Increase or remove the cap
Tip: Prefer Gemini image models for new configurations. Imagen 4 generation IDs remain available for legacy Vertex AI setups but are scheduled for retirement on Aug 17, 2026.
Authentication Errors
Error | Root Cause | Solution |
| Model doesn't accept API key auth | Use ADC: run |
| API key lacks Vertex AI permissions | Enable Vertex AI API in GCP Console, or check API key restrictions |
| No valid credentials found | Set |
Model Errors
Error | Root Cause | Solution |
| Wrong model ID for provider | AI Studio uses |
| Regional restriction on model | Try a different region ( |
| Model declined or returned empty | Try a more descriptive prompt, avoid ambiguous or restricted content |
Connection Errors
Error | Root Cause | Solution |
| Network issue or proxy needed | If behind a firewall, configure SOCKS proxy via |
| Unexpected API response | Check model ID is correct, API may be temporarily down |
Prerequisites
Python 3.10+
uv — install with
curl -LsSf https://astral.sh/uv/install.sh | sh
Local Development
git clone https://github.com/kevinten-ai/mcp-image-gen.git
cd mcp-image-gen
# Install dependencies (add --extra vertex for Vertex AI support)
uv sync
# Copy and configure environment variables
cp .env.example .env
# Edit .env with your API key
# Run the server directly
uv run image-genDebug with MCP Inspector
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-image-gen run image-genRelated Projects
mcp-video-gen — Multi-provider AI video generation MCP server
mcp-3d-gen — AI 3D model generation MCP server
License
MIT — see LICENSE for details.
Available Tools
1 toolgenerate_imageA
Generate an image from a text prompt using Google Gemini or Imagen. Provider: ai-studio. Default model: gemini-3.1-flash-image. Available models: gemini-3.1-flash-image, gemini-3-pro-image, gemini-2.5-flash-image. Tip: if you hit a 429 quota error, retry with a different model.
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Model to use (optional, default: gemini-3.1-flash-image). Available: gemini-3.1-flash-image, gemini-3-pro-image, gemini-2.5-flash-image | |
| prompt | Yes | The text prompt for image generation |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description carries full burden. It discloses the provider, default model, and available models, and a tip on handling quota errors. However, it lacks details on whether the tool has side effects (e.g., state changes), authentication requirements, rate limits, or output format (e.g., URL vs base64). The tip about quota is useful but not comprehensive.
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?
Three sentences: first states purpose, second provides provider and default, third lists models and tip. Efficient and front-loaded with no redundant information.
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?
Despite good input schema coverage, the tool lacks an output schema and the description does not explain what the tool returns (e.g., image URL, binary, or file). Also missing info about safety filters, content policies, aspect ratio, or any other generation parameters beyond prompt and model. This leaves agents guessing the response format.
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?
Schema coverage is 100% with both parameters described. The description adds value by listing available models explicitly and providing a tip about retrying on quota errors, which helps agents choose model parameter wisely. This goes beyond the schema's enum list.
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 verb "generate" and the resource "image from a text prompt" with specific provider (ai-studio) and default model. It distinguishes itself well even without sibling tools.
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?
Provides clear context that it uses Google Gemini or Imagen, and offers a practical tip for quota errors by retrying with different models. However, it does not explicitly state when not to use this tool or provide alternative scenarios.
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. Dates show when Glama detected each change.
1 tool update
v1.3.0- First observed
generate_image
TDQS
Only one tool exists, so there is zero ambiguity in tool selection. The agent can only choose this single tool.
With a single tool, naming consistency is trivially maintained. The verb_noun pattern 'generate_image' is clear and follows convention.
One tool is on the low end of what's reasonable for a server. While the server has a narrow purpose (image generation), it may be too restrictive for agents needing additional capabilities like model listing or image variation.
The tool fully covers the server's stated purpose of generating an image from a text prompt. No obvious missing functionality within the declared scope.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
Generate AI images, video, music, and sound effects, and upscale them, from any MCP client.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
Multi-model AI image and video generator. 14 models behind one OAuth-secured MCP endpoint.
Related MCP Servers
- AlicenseAqualityDmaintenanceAllows AI assistants to generate and transform high-quality images from text prompts using Google's Gemini model via the MCP protocol.334MIT
- FlicenseBqualityDmaintenanceEnables image generation and multi-turn editing sessions using the Gemini API within MCP-compatible environments. Users can create, modify, and configure images through natural language commands, supporting features like aspect ratio adjustments and session-based image transformations.5-
- AlicenseAqualityAmaintenanceEnables AI image generation and editing using Google's Gemini Multimodal Image APIs.61MIT
- AlicenseAqualityDmaintenanceMCP server for Google Gemini image generation with configurable model support, enabling text-to-image generation, image editing, and iterative refinement.641MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/kevinten-ai/mcp-image-gen'
If you have feedback or need assistance with the MCP directory API, please join our Discord server