Generate and edit images with Google Gemini (Nano Banana / Nano Banana Pro) image models.
Generate and edit images with Google Gemini (Nano Banana / Nano Banana Pro) image models.
A well-engineered MCP server for Google Gemini media generation with proper authentication, secure credential handling, and thoughtful error management. The codebase demonstrates strong engineering practices with comprehensive testing and appropriate permission scoping. Minor code quality observations around broad error handling do not materially impact security. Supply chain analysis found 2 known vulnerabilities in dependencies (0 critical, 1 high severity). Package verification found 1 issue.
3 files analyzed · 6 issues found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
This plugin requests these system permissions. Most are normal for its category.
Set these up before or after installing:
Environment variable: GEMINI_API_KEY
Environment variable: GEMINI_IMAGE_MODEL
Environment variable: GEMINI_OUTPUT_DIR
Environment variable: GEMINI_INPUT_DIR
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-chrischall-gemini-mcp": {
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here",
"GEMINI_INPUT_DIR": "your-gemini-input-dir-here",
"GEMINI_OUTPUT_DIR": "your-gemini-output-dir-here",
"GEMINI_IMAGE_MODEL": "your-gemini-image-model-here"
},
"args": [
"-y",
"@chrischall/gemini-mcp"
],
"command": "npx"
}
}
}From the project's GitHub README.
MCP server for Google Gemini media generation. Exposes eight tools to Claude over stdio: list available models, generate/edit/compose images, generate a consistent set of images from a master prompt, multi-turn image refinement (Interactions API), video generation (omni), music generation (Lyria), and an async result poll for long generations. Output is written to disk by default (path returned) or returned inline as base64. Built on the Gemini v1beta API (generativelanguage.googleapis.com) using the Nano Banana / Nano Banana Pro (images), omni (video), and Lyria (music) model families.
Developed and maintained by AI (Claude Code).
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY | Yes | Your Google Gemini API key (aistudio.google.com/apikey) |
GEMINI_IMAGE_MODEL | No | Override the default image model (default: gemini-3.1-flash-image) |
GEMINI_OUTPUT_DIR | No | Default directory for generated images (default: current working directory) |
GEMINI_INPUT_DIR | No | Directory to resolve bare input-image filenames against (so images: ["foo.jpg"] works) |
GEMINI_TIMEOUT_MS | No | Upstream request timeout in ms (default: 60000, or 120000 for image_size: "4K"); each generation tool also takes a per-call timeout_ms |
GEMINI_HEARTBEAT_MS | No | Progress-notification cadence in ms while a generation runs (default: 10000; 0 disables) — keeps MCP hosts that reset their timeout on progress from timing out long generations |
GEMINI_CHAIN_RETRY_MS | No | How long to wait out interactions-store lag when a chained call 404s (default: 120000; 0 disables retrying) |
4K / Pro-model generations can outrun an MCP host's own tools/call timeout (error -32001).
The server sends notifications/progress heartbeats so hosts that reset their timeout on
progress wait it out. If the host still gives up, the server-side generation usually completes
anyway: the image is written to the output dir, gemini_interact also writes an
<image>.json sidecar recording the interaction_id, and continue_last: true resumes the
interaction the lost response belonged to.
A 404 on a request carrying previous_interaction_id is not proof the chain expired. The
only 404 body observed live is generic — "Requested entity was not found." — and never names
which entity. An unknown or renamed model id, and an expired Files API files/… uri
(~48h TTL), return exactly the same thing. So the server no longer asserts a cause it can't
establish: the upstream text is surfaced verbatim, and gemini_interact runs an experiment to
find out which it was.
Most often the id isn't missing at all — it just isn't visible yet. The interactions store is
eventually consistent, and a freshly created id can 404 while the same id resolves fine minutes
later; heavy turns (4K, Pro, thinking_level: high) are the likeliest to hit it, which is
exactly the turn you most want to chain from. So a chained 404 is retried with exponential
backoff for up to 120s (GEMINI_CHAIN_RETRY_MS) before anything is declared broken. The
404 generates nothing and isn't billed, so the wait costs only time.
After that budget is spent, the tool looks up that id's sidecar, re-attaches the image it produced, and re-issues the request without the chain:
chain_recovered: { expired_interaction_id, reanchored_on }. The 404'd attempt
generates nothing, so this costs the one generation you'd have paid for re-anchoring manually.files/… uri instead of being
sent to chase an interaction that was fine all along.Separately, continue_last no longer dies with the server process: with no in-memory id it
resumes from the newest <image>.json sidecar in the output dir and reports
continued_from_sidecar: true. That case was never an expired chain at all — the interaction
was alive upstream the whole time; only our memory of its id was gone.
For hosts whose timeout can't be tamed (e.g. Claude Desktop, a fixed ~30s cap that ignores progress), two guards make re-issuing safe and unnecessary:
async: true returns a job_id immediately instead of the image, so the call can't
time out at all; poll gemini_get_result with the job_id until it's done.idempotency_key makes a repeat call idempotent — a retry with the same key returns the
recorded result (reused: true) instead of billing a second generation. (Even without a key,
two identical in-flight calls are deduplicated automatically.)| Tool | Description |
|---|---|
gemini_list_models | List available Gemini image models and the current default |
gemini_image_generate | Generate image(s) from a text prompt |
gemini_image_edit | One-off edits or multi-image composition with a text instruction (for a series of edits, use gemini_interact) |
gemini_image_set | Generate a master image plus N consistent images referencing it |
gemini_interact | Preferred tool for iterative refinement: multi-turn generation/editing via the Interactions API — chain the returned interaction_id via previous_interaction_id (or continue_last: true) |
gemini_video_generate | Generate a short video (text→video, image→video, or edit) via the Gemini omni model (preview); written to disk as MP4 |
gemini_music_generate | Generate music from a text prompt via a Lyria model — lyria-3-clip-preview (~30s, default) or lyria-3-pro-preview (longer, WAV-capable); written to disk as MP3/WAV (preview) |
gemini_get_result | Fetch an async generation started with async: true by its job_id (status running → done result). Lets a long generation outlive a host's tools/call timeout |
{
"mcpServers": {
"gemini": {
"command": "npx",
"args": ["-y", "@chrischall/gemini-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
See SKILL.md for full usage documentation.
Be the first to review this server!
by Modelcontextprotocol · AI & ML
Dynamic and reflective problem-solving through structured thought sequences
by Toleno · Developer Tools
Toleno Network MCP Server — Manage your Toleno mining account with Claude AI using natural language.
by mcp-marketplace · Developer Tools
Create, build, and publish Python MCP servers to PyPI — conversationally.