Public
MCP server for Google Imagen image generation
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Gemini MCP Server

An MCP (Model Context Protocol) server exposing Google's Gemini API β€” image generation (Imagen), image editing (Imagen 3), video generation (Veo 3.1), and image analysis (Gemini vision) β€” as tools for Claude and other MCP clients.

Deployed on Val Town via the MCP Streamable HTTP transport.

Quick Start

1. Set your API key

πŸ‘‰ Add GEMINI_API_KEY here: https://www.val.town/x/noppo0152/imagen-mcp-server/environment-variables?key=GEMINI_API_KEY

Get a key from Google AI Studio.

2. Configure your MCP client

{ "mcpServers": { "gemini": { "url": "https://noppo0152--fead52e689ac11f1be121607ee4eb77e.web.val.run", "transport": "http" } } }

Available Tools

generate_image

Text-to-image generation with Google Imagen.

ParameterTypeRequiredDescription
promptstringβœ…Image description (English, max 480 tokens)
modelstring❌imagen-4.0-generate-001 (default), imagen-4.0-fast-generate-001, imagen-3.0-generate-002
sampleCountnumber❌1–4 images. Default: 1
aspectRatiostring❌1:1, 16:9, 9:16, 4:3, 3:4
personGenerationstring❌dont_allow, allow_adult, allow_all
imageSizestring❌1K or 2K (only Imagen 4)
seednumber❌Reproducible generation seed

edit_image

Image-to-image editing with Google Imagen 3.

ParameterTypeRequiredDescription
promptstringβœ…Edit description
imagestringβœ…Base64-encoded source image (no data URI prefix)
mimeTypestringβœ…image/png, image/jpeg, image/webp
modelstring❌Defaults to imagen-3.0-generate-002
sampleCountnumber❌1–4. Default: 1
aspectRatiostring❌1:1, 16:9, 9:16, 4:3, 3:4
personGenerationstring❌dont_allow, allow_adult, allow_all

generate_video

Text-to-video generation with Google Veo 3.1 (8s clips with native audio).

ParameterTypeRequiredDescription
promptstringβœ…Detailed scene description with camera, dialogue, sound
modelstring❌veo-3.1-generate-preview (default)
aspectRatiostring❌16:9 (landscape, default) or 9:16 (portrait)
resolutionstring❌720p (default), 1080p, 4k

⏱️ This is a long-running operation (1–5 min). The server polls until completion and returns base64-encoded MP4 data.

analyze_image

Image analysis and prompt engineering with Gemini vision models.

ParameterTypeRequiredDescription
imagestringβœ…Base64-encoded image (no data URI prefix)
mimeTypestringβœ…image/png, image/jpeg, image/webp, image/heic, image/heif
promptstring❌Question or instruction. Default: describe image + suggest enhanced generation prompt
modelstring❌gemini-2.5-flash (default), gemini-2.0-flash, gemini-1.5-pro

MCP Protocol

Implements the MCP Streamable HTTP transport (JSON-RPC 2.0):

  • POST β€” initialize, tools/list, tools/call, ping
  • GET β€” SSE endpoint for server-to-client streaming

Architecture

main.ts   β€” MCP protocol handler (JSON-RPC, HTTP transport)
tools.ts  β€” Tool definitions + Google API integrations

⚠️ Deprecation Notice

Imagen models are deprecated and will shut down on August 17, 2026. Google recommends migrating to Nano Banana (gemini-2.5-flash-image) for future image generation needs.