Skip to content

Gemini Images (Nano Banana)

Build an xmcp server that generates and edits images with Google's Gemini image models and returns them inline.

For the complete documentation index, see llms.txt. Markdown variants of every page are available by appending .md to the URL.

Generate and edit images with Gemini's Nano Banana models. Start with the runnable example.

Configure access

Create an API key in Google AI Studio. The default model is gemini-nano-banana-2.1; set GEMINI_IMAGE_MODEL to use another, such as gemini-3-pro-image.

Shell

MCP clients send MCP_API_KEY as x-api-key on every request, compared in constant time. The server is stateless: it keeps no sessions and no job records. The server calls the Gemini Interactions API at https://generativelanguage.googleapis.com/v1beta/interactions with the x-goog-api-key header. Requests are never retried, because a retry would bill a new image. All authorized MCP clients share the same provider account and its credits.

Available tools

ToolPurpose
generate-imageGenerate an image from a prompt.
edit-imageEdit or combine up to 4 images sent as base64 data.

Results

The tool returns each image inline as MCP image content, with a JSON summary first.

Images come back in the response, so there are no jobs. Source images for edit-image are sent inline as base64, up to about 5 MB each, because this server never downloads client-supplied URLs. The example raises xmcp's request body limit to 30 MB to fit four of them. The server waits up to two minutes for an image. If Gemini declines a prompt and returns no image, the tool returns an error.

Run the example

Follow the example README for installation and startup. Its tests replace every provider request with a local fake, so they need no credentials.

Tested against the Gemini image generation guide on November 24, 2026.

One framework to rule them all