Image generation with Google Gemini 3.1 Flash: 512px-4K, reference images, search grounding
io.github.nikships/ultimate-image-gen-mcp (MCP) Server
This MCP server performs image generation using Google Gemini 3.1 Flash. It supports output sizes from 512px up to 4K, can use reference images, and can apply search grounding to influence the generated results. The server is identified by slug io-github-nikships-ultimate-image-gen-mcp.
๐ ๏ธ Key Features
Image generation via Google Gemini 3.1 Flash
Configurable image size: 512pxโ4K
Reference image support
Search grounding
๐ Use Cases
Generating images at specific resolutions (512px through 4K)
Creating outputs constrained by provided reference images
Producing images guided by search grounding
โก Developer Benefits
Integrates Gemini 3.1 Flash image generation through MCP
Parameterized generation for multiple target resolutions
Inputs can include reference images and search grounding
โ ๏ธ Limitations
Only described as supporting Gemini 3.1 Flash image generation, 512pxโ4K sizing, reference images, and search grounding
MCP server for Google's Gemini 3.1 Flash Image โ fast image generation with advanced reasoning, 512pxโ4K resolution, up to 14 reference images, Google Search grounding, and automatic thinking mode.
Transparent Backgrounds: Flip one flag โ ready-to-use transparent PNG/WebP cut-outs with a real alpha channel, recovered by a two-pass difference matte (generate on white โ edit to black โ solve for alpha). True soft edges/glow/glass, no color halo. Pillow only โ no extra dependencies. Costs a second model call (~2x).
Dedicated App-Icon / Logo Tool: generate_app_icon forces a square, transparent, 1024px PNG every time โ no way to get a non-square or opaque-background icon
This model is different. Unlike traditional image generators that rely solely on training data, Gemini 3.1 Flash has live access to Google Search and Image Search. It can find actual references for products, people, events, or anything that exists online. "Way of Wade 12" โ generates the REAL shoe. "Tony Hawk" โ finds real photos. Don't over-prompt โ let the model cook.
Server Features
Batch Processing: Generate multiple images in parallel (up to 8 concurrent)
26 Expert Prompt Templates: MCP slash commands for photography, cinematics, storyboards, and more
Images are saved to ~/gemini_images by default. Add "OUTPUT_DIR": "/your/path" to customize.
Tools
generate_image
Generate an image with Gemini 3.1 Flash Image.
Parameter
Type
Default
Description
prompt
string
required
Text description. Less is more โ "Tony Hawk kickflip" beats a long description. The model with search can find references automatically.
aspect_ratio
string
1:1
One of: 1:11:41:82:33:23:44:14:34:55:48:19:1616:921:9
image_size
string
2K
512px, 1K, 2K, or 4K
output_format
string
png
png, jpeg, or webp
reference_image_paths
list
[]
Up to 14 local image paths (10 objects + 4 characters)
enable_google_search
bool
false
USE THIS for products, people, events โ anything that exists now. The model searches Google for real info.
enable_image_search
bool
false
USE THIS for visual references. The model finds actual images to work from. This is huge โ it can reference real photos of anyone/anything.
thinking_level
string
minimal
minimal (fast) or high (best quality)
response_modalities
list
["TEXT","IMAGE"]
["TEXT","IMAGE"], ["IMAGE"], or ["TEXT"]
transparent_background
bool
false
Produce a transparent PNG/WebP cut-out via the two-pass difference matte (~2x cost; see below)
preserve_original
bool
true
Also keep the pass-1 (white-background) image, not just the cut-out
alpha_output_format
string
png
Alpha-capable output format: png or webp
Image size guide:
512px โ fastest, lowest cost (0.5K)
1K โ fast, good for testing (~1-2 MB)
2K โ recommended for most use cases (~3-5 MB)
4K โ maximum quality for production assets (~8-15 MB)
Transparent backgrounds โ set one flag, get a real alpha cut-out
Just set transparent_background=true. You get back a ready-to-use transparent PNG/WebP (real alpha channel) at transparent_path โ no manual masking, no second tool, no follow-up steps.
Generating an app icon or logo? Use the dedicated generate_app_icon tool instead โ it forces square + transparent + 1024px PNG so the icon constraints can't be set wrong.
Under the hood this is a two-pass difference matte. The subject is rendered once on a pure white (#FFFFFF) background, that image is edited to a pure black (#000000) background, and the two frames are combined to solve for alpha per pixel: since obs_white โ obs_black = (1โฮฑ)ยท255 on every channel, ฮฑ = 1 โ mean(obs_white โ obs_black)/255, and the foreground colour is un-premultiplied from the black frame. Because there's no colour key, there's no green spill/halo; alpha is fractional, so soft edges, glow, glass, and faint shadows all survive. Pillow-only, zero ML downloads โ but it costs a second model call (~2x tokens/latency).
The technique assumes the edit pass changed only the background. If the model drifts the subject between passes, the matte degrades โ the result still returns (aligned/alignment_error flag it, with a loud post_processing_warnings entry) so you can decide whether to regenerate.
Each returned image gains: transparent_path, background_removed, background_removal_mode ("difference_matte"), aligned, alignment_error, alpha_output_format, and post_processing_warnings. By default the pass-1 (white-background) original is preserved alongside the cut-out (preserve_original=true).
It nails crisp-edged subjects and soft glow/glass. The one failure mode is the edit pass drifting the subject (flagged via aligned: false) โ regenerate if edges look ghosted.
generate_app_icon
Purpose-built for app icons and logos. Square, transparent, and 1024px are forced โ there is no aspect_ratio, image_size, output_format, or transparent_background knob to get wrong. Every result is a real alpha-channel PNG at transparent_path, ready to drop into a .iconset directory and convert with iconutil -c icns.
Parameter
Type
Default
Description
prompt
string
required
Describe the icon/logo mark only โ framing & transparency are handled
reference_image_paths
str | list
null
Brand/style reference image path(s), up to 14
enable_google_search
bool
false
Ground design in real web references
enable_image_search
bool
false
Use Google Image Search for visual context
thinking_level
string
high
minimal or high (icons reward high)
allow_icon_words_in_prompt
bool
false
Escape hatch โ bypass the prompt guard only when a word like "logo" is genuinely part of the subject
The prompt must describe ONLY the subject, never the deliverable. This tool already turns whatever you describe into an icon, so framing words like "app icon", "logo", "favicon", or "squircle" in the prompt are rejected (set allow_icon_words_in_prompt=true only if such a word is literally part of the depicted subject). Right: "a glowing electric-blue magnifying glass over a network graph". Wrong: "an app icon of a magnifying glass".
jsonc
// generate_app_icon(prompt="a glowing electric-blue magnifying glass over a network graph"){"images":[{"transparent_path":"/path/to/...-transparent.png",// square, 1024px, alpha"background_removed":true,"alpha_output_format":"png"}]}
batch_generate
Generate multiple images in parallel.
Parameter
Type
Default
Description
prompts
list
required
List of prompt strings (max 8)
aspect_ratio
string
1:1
Aspect ratio applied to all images
image_size
string
2K
Resolution for all images
output_format
string
png
Format for all images
response_modalities
list
["TEXT","IMAGE"]
Modalities for all images
batch_size
int
8
Max concurrent requests
enable_image_search
bool
false
Use Google Image Search for visual context
thinking_level
string
minimal
minimal or high
transparent_background
bool
false
Apply the two-pass difference matte to every image (each costs a second model call)
preserve_original
bool
true
Keep the pass-1 (white-background) images too
alpha_output_format
string
png
Transparent output format: png or webp
MCP Prompt Templates
26 expert prompt templates are available as MCP slash commands in Claude Code (type / to browse). Each template returns a crafted prompt and recommended parameters ready to pass directly to generate_image or batch_generate. For app icons and logos, use the dedicated generate_app_icon tool instead.
Command
Description
Default aspect ratio
photography_shot
Photorealistic shot with lens/lighting specs
16:9
cinematic_scene
Film still with cinematography language
21:9
product_mockup
Commercial e-commerce photography
1:1 or 4:5
batch_storyboard
Multi-scene storyboard โ calls batch_generate
16:9
macro_shot
Extreme macro with micro-snoot lighting
1:1
fashion_portrait
Editorial fashion with gobo shadow patterns
4:5
technical_cutaway
Stephen Biesty-style cutaway diagram
3:2, 4K, IMAGE only
flat_lay
Overhead knolling photography
1:1
action_freeze
High-speed strobe with motion blur background
16:9
night_street
Moody night street with practical light sources
16:9
drone_aerial
Straight-down golden hour aerial
4:5, 4K, IMAGE only
stylized_3d_render
UE5-style render with subsurface scattering
1:1, IMAGE only
sem_microscopy
Scanning electron microscope false-color
1:1, IMAGE only
double_exposure
Silhouette-blended double exposure
2:3, IMAGE only
architectural_viz
Ray-traced architectural visualization
3:2, 4K
isometric_illustration
Orthographic isometric 3D illustration
1:1, IMAGE only
food_photography
High-end backlit food photography
4:5
motion_blur
Rear-curtain sync slow shutter sequence
16:9
typography_physical
Text embedded in physical environment
16:9, 4K, IMAGE only
retro_futurism
1970s cassette-futurism analog sci-fi
4:3, IMAGE only
surreal_dreamscape
Surrealist impossible physics scene
1:1, IMAGE only
character_sheet
Video game character concept art sheet
3:2, 4K, IMAGE only
pbr_texture
Seamless PBR texture map with raking light
1:1, IMAGE only
historical_photo
Period-accurate photography with film emulation
4:5
bioluminescent_nature
Long-exposure bioluminescence macro
1:1
silhouette_shot
Cinematic pure-black silhouette master shot
21:9, 4K
Configuration
Variable
Default
Description
GEMINI_API_KEY
โ
Required. Google Gemini API key
OUTPUT_DIR
~/gemini_images
Directory where images are saved
DEFAULT_IMAGE_SIZE
2K
Default resolution (1K, 2K, 4K)
DEFAULT_MODEL
gemini-3-pro-image-preview
Default model
ENABLE_PROMPT_ENHANCEMENT
false
Auto-enhance prompts by default
ENABLE_GOOGLE_SEARCH
false
Enable Google Search grounding by default
REQUEST_TIMEOUT
60
API timeout in seconds
MAX_BATCH_SIZE
8
Max parallel requests in batch mode
LOG_LEVEL
INFO
Logging level
Troubleshooting
spawn uvx ENOENT โ Claude Desktop can't find uvx. Use the full path:
json
"command":"/Users/yourusername/.local/bin/uvx"
Find it with: which uvx
GEMINI_API_KEY not found โ Set the key in your MCP config env block or in a .env file. Get a free key at Google AI Studio.
Content blocked by safety filters โ Rephrase the prompt to avoid sensitive content.
Rate limit exceeded โ Wait and retry, or upgrade your API quota.
Images not saving โ Check OUTPUT_DIR exists and is writable: mkdir -p /your/output/path.