Gemini Image MCP Server
Generates and edits images through Google's Gemini image models (gemini-3-pro-image-preview, gemini-3.1-flash-image-preview) using a Google AI API key, supporting 14 aspect ratios, resolution tiers from 512 to 4K, reference-image-guided generation and watermark overlays.
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 Image MCP Server generate a 16:9 watercolor illustration of a fox in a snowy forest"
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 MCP Server
A Model Context Protocol (MCP) server for generating and editing images using Google's Gemini AI models. Provides two tools that any MCP client can use to create images from text descriptions and modify existing images with natural language instructions.
Features
14 aspect ratios natively supported via Gemini's
imageConfig:1:1,1:4,1:8,2:3,3:2,3:4,4:1,4:3,4:5,5:4,8:1,9:16,16:9,21:94 resolution tiers:
512(Flash models only),1K,2K,4KMultiple Gemini models:
gemini-3-pro-image-preview(high-fidelity, accurate text) andgemini-3.1-flash-image-preview(fast, cost-efficient), with any model string acceptedImage editing: modify existing images with natural language instructions, including aspect ratio changes
Reference images: provide context images to guide generation style and composition
Watermarking: overlay brand logos or watermarks with configurable positioning
CLI included: standalone command-line interface for terminal workflows
MCP + stdio transport: works with any MCP client (Claude Desktop, Claude Code, VS Code, Cursor, and more)
Related MCP server: nanobanana-mcp
Quick Start
Prerequisites
A Google AI API key is required. Get one free at Google AI Studio.
Install and Run
npx gemini-image-mcp-serverOr install globally:
npm install -g gemini-image-mcp-serverInstallation
Configure the server in your MCP client. The server communicates over stdio.
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "gemini-image-mcp-server"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}claude mcp add gemini-image -- npx -y gemini-image-mcp-serverThen set your API key in the environment or in your .claude/settings.json:
{
"mcpServers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "gemini-image-mcp-server"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}Add to your VS Code settings.json:
{
"mcp": {
"servers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "gemini-image-mcp-server"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}
}Add to your Cursor MCP configuration:
{
"mcpServers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "gemini-image-mcp-server"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}Clone and build, then point your MCP client to the compiled entry:
git clone https://github.com/amineew-cell/gemini-image-mcp-server.git
cd gemini-image-mcp-server
npm install
npm run buildUse in your MCP client config:
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["/absolute/path/to/gemini-image-mcp-server/dist/index.js"],
"env": {
"GOOGLE_API_KEY": "your-api-key-here"
}
}
}
}Configuration
Environment Variable | Required | Description |
| Yes | Google AI API key from AI Studio |
Tools
generate_image
Create a new image from a text description. Use this tool when you need to generate fresh visual content.
Best for: product shots, illustrations, social media graphics, concept art, textures, backgrounds.
Parameters:
Parameter | Type | Required | Default | Description |
| string | Yes | Detailed description of the image to generate | |
| string | No |
| Output aspect ratio. One of: |
| string | No |
| Resolution tier. One of: |
| string | No |
| Gemini model ID. Use |
| string | No | Style hint (e.g., "minimalist", "watercolor", "photorealistic") | |
| string[] | No | File paths to reference images that guide the generation | |
| string | No | cwd | Where to save the image. Can be a directory or full file path. |
| string | No | Path to a watermark image to overlay | |
| string | No |
| Watermark corner: |
Returns: The absolute file path of the saved image.
Example tool call:
{
"name": "generate_image",
"arguments": {
"description": "A brown leather wallet on a white marble surface, overhead studio lighting, minimal composition",
"aspectRatio": "4:5",
"imageSize": "2K",
"outputPath": "./images/wallet-hero.png"
}
}edit_image
Modify an existing image using natural language instructions. Use this tool when you have an image and want to change specific elements, adjust composition, or transform the aspect ratio.
Best for: retouching, background changes, adding/removing elements, recomposing for different aspect ratios, style transfer.
Parameters:
Parameter | Type | Required | Default | Description |
| string | Yes | Instructions describing the edits to apply | |
| string | Yes | Path to the source image to edit | |
| string | No | Output aspect ratio. Use this to recompose an image for a different format (e.g., square to portrait). | |
| string | No | Resolution tier for the output | |
| string | No |
| Gemini model ID |
| string | No | cwd | Where to save the edited image |
Returns: The absolute file path of the saved edited image.
Example tool call:
{
"name": "edit_image",
"arguments": {
"description": "Extend the background naturally to fill a taller portrait composition. Keep the subject centered.",
"image": "./images/product-square.png",
"aspectRatio": "4:5",
"outputPath": "./images/product-portrait.png"
}
}Choosing Between Tools
Scenario | Tool | Why |
Create an image from scratch |
| No source image needed |
Change aspect ratio of existing image |
| Preserves content while recomposing |
Add/remove elements from a photo |
| Modifies specific parts |
Generate variations inspired by a reference |
| Uses reference as style guide, creates new content |
Apply a watermark |
| Built-in watermark support |
Usage Examples
These are natural language prompts you can use with any MCP client:
Generate a product shot for Instagram:
Generate an image of a leather notebook on a wooden desk with soft window light. Use 4:5 aspect ratio for Instagram feed.
Create a wide banner:
Create a panoramic minimalist workspace scene with a pen and folio. 16:9 ratio, 2K resolution.
Edit an existing image:
Edit this image: extend the background to change it from square to 4:5 portrait format. Keep the subject centered and extend the background naturally.
Generate with a reference image:
Generate a product shot inspired by this reference image, but with a darker background and warmer lighting. Use the same composition style.
High-resolution texture:
Generate a close-up of leather grain texture with warm directional lighting. Square format, 2K resolution.
CLI
The server includes a standalone CLI for terminal workflows.
Generate
gemini-image generate \
--prompt "A leather wallet on white marble, studio lighting" \
--aspect 4:5 \
--size 2K \
--output ./images/wallet.pngEdit
gemini-image edit \
--prompt "Make the background darker and add warm highlights" \
--input ./images/original.png \
--aspect 4:5 \
--output ./images/edited.pngAll CLI Flags
Generate command:
Flag | Short | Description |
|
| Image description (required) |
|
| Aspect ratio (e.g., |
|
| Image size: |
|
| Gemini model ID |
|
| Style hint |
|
| Reference image path (repeatable) |
|
| Output path |
| Watermark image path | |
| Watermark corner position |
Edit command:
Flag | Short | Description |
|
| Edit instructions (required) |
|
| Source image path (required) |
|
| Output aspect ratio |
|
| Output image size |
|
| Gemini model ID |
|
| Output path |
Available Models
Model | Best For | Notes |
| Complex design, high-fidelity output, accurate text in images | Default. Higher quality, slower. |
| High-volume generation, fast iteration, cost-efficient | Faster and cheaper. Supports |
You can pass any valid Gemini model ID via the model parameter.
Troubleshooting
"GOOGLE_API_KEY environment variable is required"
The API key is not set. Ensure your MCP client config includes the env block with GOOGLE_API_KEY, or export it in your shell for CLI usage.
"models/xxx is not found" (404 error)
The model ID is invalid or not available for your API key. Check:
The model name is spelled correctly (e.g.,
gemini-3-pro-image-preview, notgemini-3-pro)Your API key has access to the model (some models require allowlisting)
Image has wrong aspect ratio
Verify you are passing the aspectRatio parameter. If omitted, the default is 1:1. The ratio must be one of the 14 supported values.
"Gemini finish reason: SAFETY" or empty response
The prompt or generated content triggered Gemini's safety filters. Try:
Rephrasing the prompt to be more specific and less ambiguous
Using a different model (Flash may have different filtering thresholds)
Image file not saved / permission error
Ensure the output directory exists or the server has permission to create it
If specifying a directory, end the path with
/Use absolute paths to avoid ambiguity
Server not connecting to MCP client
Verify the
commandandargsin your client config are correctCheck that
nodeis in your PATHLook at stderr output for error messages (the server logs to stderr)
Try running
npx gemini-image-mcp-serverdirectly to verify it starts
Development
git clone https://github.com/amineew-cell/gemini-image-mcp-server.git
cd gemini-image-mcp-server
npm install
npm run buildSee CONTRIBUTING.md for detailed development guidelines.
License
Available Tools
2 toolsedit_imageB
Modify an existing image using Google Gemini AI based on a text instruction. Provide the path to the image you want to edit and describe the changes that should be applied.
Inputs: image (required), description (required), model, imageSize, +2 more.
generate_imageA
Create a new image using Google Gemini AI from a text description, optionally providing reference images to guide the result. Use the edit_image tool when you need to modify an existing asset.
Inputs: description (required), model, style, images, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools are cleanly separated by intent: generate_image creates new assets and edit_image modifies existing ones. The generate_image description even explicitly points to edit_image for modifications, eliminating overlap.
Both names use the same verb_noun pattern (generate_image, edit_image) with a shared noun, making the convention immediately predictable.
Two tools is on the thin side for an image-generation server, but the create/edit split is the core workflow. It feels minimal rather than mismatched, and only earns a borderline score because it is at the low end of typical ranges.
The create-and-modify lifecycle for images is covered, which are the essential operations. Minor gaps exist for auxiliary needs like batch generation, variations, or explicit upscale/metadata operations, but agents can work around these via the two core tools.
Maintenance
Related MCP Connectors
Generate images from Claude, ChatGPT, Cursor and Codex with 12 top AI image models. Up to 4 images per call, SVG vectorization, background removal, upscaling and image-to-video. Remote MCP with OAuth, no API keys.
Generate images with any major model — one API key, one prepaid balance, one MCP.
Edit images over MCP with object removal, background removal, and guided generative edits.
Generate images, video, audio and short films with 140+ AI models from any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI-powered image generation and editing using Gemini and Imagen models, supporting text-to-image, image editing, and multi-image composition through MCP tools.MIT
- AlicenseAqualityBmaintenanceEnables text-to-image generation and image editing or composition with Google's Gemini image models via MCP tools, prompts, and resources. Supports automatic model selection, aspect ratio and resolution control, curated prompt templates, and three credential modes (Gemini API key, Vertex AI Express Mode, or ADC).6471 npm1MIT
- AlicenseNot gradedqualityAmaintenanceEnables any MCP client to create and edit images from natural-language requests, automatically enriching short prompts with composition, lighting, and camera details while supporting Gemini, OpenAI, and BytePlus Seedream with fast, balanced, or quality presets.1,225 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants and MCP clients to generate and edit images through Gemini, OpenAI, or BytePlus Seedream, with automatic prompt optimization, quality presets, aspect ratios, image sizes, and input-image support.1,225 npmMIT