Skip to main content
Glama
gemini-media-mcp

gemini-media-mcp

by mordor-forge

gemini-media-mcp

CI Go License

An MCP server for Google's generative media models: images (Nano Banana 2.1 / Pro), video (Veo 3.1 and Gemini Omni Flash), speech (Gemini 3.8 TTS) and music (Lyria 3.5). It ships as a single Go binary, speaks stdio and Streamable HTTP (MCP 2026-07-28), works with the Gemini API or Vertex AI, and comes with agent skills that teach agents the whole workflow, plus plugin packaging for Claude Code, Codex, Gemini CLI, VS Code/Copilot, Cursor and more.

https://github.com/user-attachments/assets/f46970b3-82a6-4364-a40a-922103dbbc70

An agent using the server one tool at a time: images and edits, a video clip and its claymation restyle, a 768 px portrait tiled up to 8K, and an extended shot. The footage, the narration and the music all came from the server.

  • Current models, updated without a release. A built-in catalog records IDs, aliases, lifecycle, parameters and prices. Retired models redirect to their replacement, and new model IDs work before the catalog knows them. You can override or extend the catalog with a hot-reloaded YAML file.

  • Cost-aware. Every result reports its estimated cost, and estimate_cost compares options before you spend. Spend is recorded in a ledger, capped by session, daily and monthly budgets, and calls above a threshold need explicit approval.

  • Agent-friendly. Each tool matches a workflow, and errors come back as [kind] message + Hint. Image results include inline previews, and outputs can be chained by URI. Video runs as async jobs with long-polling and progress notifications.

  • Skills included. Six agent skills cover each medium, multi-asset productions and upscaling past 4K. The upscale skill re-renders a photo tile by tile and stitches the tiles into an 8K image.

  • Robust. Backend and credentials are detected the way the Google SDKs do it. Vertex locations are chosen per model, retries and timeouts are built in, files are written atomically with provenance, and HTTP mode ships with security defaults.

Upgrading from v0? The tools changed. See the migration table. The review also covers what was broken, why, and the design of v1.

Quick start

  1. Get credentials. Either:

    • an API key from Google AI Studio (GEMINI_API_KEY), or

    • a Google Cloud project with Vertex AI enabled (GOOGLE_CLOUD_PROJECT plus gcloud auth application-default login).

  2. Install the binary. On macOS or Linux:

    mkdir -p ~/.local/bin   # must be on your PATH
    os=$(uname -s | tr '[:upper:]' '[:lower:]'); arch=$(uname -m | sed 's/x86_64/x64/; s/aarch64/arm64/')
    curl -fsSL "https://github.com/mordor-forge/gemini-media-mcp/releases/latest/download/$os.$arch.gemini-media-mcp.tar.gz" \
      | tar -xz -C ~/.local/bin gemini-media-mcp
    gemini-media-mcp version

    On Windows, download the windows zip from the latest release and put gemini-media-mcp.exe on your PATH. With Go 1.26+: go install github.com/mordor-forge/gemini-media-mcp/cmd/gemini-media-mcp@latest.

    The Gemini CLI extension, the Claude Desktop bundle and the Docker image include the binary, so they skip this step.

  3. Add the server to your agent. Every config below runs gemini-media-mcp from your PATH.

    Claude Code (plugin: server plus skills), from the shared mordor-forge marketplace:

    /plugin marketplace add mordor-forge/claude-plugins
    /plugin install gemini-media@mordor-forge

    If you added mordor-forge from this repository before, switch with /plugin marketplace remove mordor-forge first. Your installed plugin keeps working either way. or just the server: claude mcp add gemini-media -e GEMINI_API_KEY=... -- gemini-media-mcp

    Codex (~/.codex/config.toml):

    [mcp_servers.gemini-media]
    command = "gemini-media-mcp"
    env_vars = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_CLOUD_PROJECT", "GOOGLE_CLOUD_LOCATION"]
    tool_timeout_sec = 300   # 4K images and video polls can exceed the 60 s default

    Gemini CLI (paid API keys, Vertex AI and Gemini Code Assist only, since June 2026): gemini extensions install https://github.com/mordor-forge/gemini-media-mcp

    Antigravity CLI: add the server to ~/.gemini/config/mcp_config.json, as shown in the install snippets.

    Claude Desktop: download gemini-media-mcp-<version>.mcpb from the latest release and open it.

    VS Code / Copilot: code --add-mcp '{"name":"gemini-media","command":"gemini-media-mcp"}'

    Cursor, Windsurf and other mcpServers-style clients (Zed, OpenCode and Goose use their own formats, see below):

    { "mcpServers": { "gemini-media": { "command": "gemini-media-mcp", "env": { "GEMINI_API_KEY": "..." } } } }

    If a desktop app reports that gemini-media-mcp was not found, it doesn't see your shell's PATH: use the full path from command -v gemini-media-mcp. Every client, plus Docker and the skills installer, is covered in packaging/INSTALL-SNIPPETS.md.

  4. If your agent doesn't forward environment variables (plugins often don't), store the key once:

    echo "$GEMINI_API_KEY" | gemini-media-mcp configure --api-key-stdin
    gemini-media-mcp doctor   # checks credentials, backend and model availability

To run it in Docker instead: docker run -i --rm --user "$(id -u):$(id -g)" -e GEMINI_API_KEY -v "$PWD/media:/output" -v gemini-media-state:/state ghcr.io/mordor-forge/gemini-media-mcp (--user makes the generated files yours on Linux; the named /state volume keeps spend accounting and video jobs between runs).

Related MCP server: Gemini Media MCP

Tools

Tool

What it does

generate_image

Text-to-image with up to 14 reference images, 1K–4K, many aspect ratios, 1–4 variations, optional Google Search grounding

edit_image

Change an existing image (add/remove/restyle/relight/outpaint) while keeping the rest

tile_image

Step 1 of an upscale to any target size (1K–16K): plan the cheapest crops that cover it, shaped to the edit model's aspect ratios (one tile up to about 4K, a grid beyond, or regions such as faces). Free and local

stitch_tiles

Align the edited tiles with the image, match their color, blend the overlaps and save one large PNG (8K by default). Free and local

generate_video

Clip with native audio from text, a first frame, first+last frames, or reference images: Veo (4–8 s, up to 3 references) or Gemini Omni Flash (omni: 3–10 s, 360p drafts to 4K, up to 10 references). Returns a jobId

get_video

Wait for a job (long-poll, default 45 s); downloads the video when done. Safe to repeat

extend_video

Continue a finished clip: Omni adds up to 10 s (40 s total), Veo about 7 s (up to 148 s total)

edit_video

Change a finished clip or a video file of up to 10 s with an instruction (Gemini Omni)

generate_speech

Text-to-speech (WAV): one voice, or a two-speaker dialogue, with per-line style control and 30 voices

generate_music

30-second clips or full songs with lyrics, structure tags, tempo, instrumental mode and image inspiration

list_models

Current models, aliases, status, prices; detail for supported parameters, live to check what your key can use

estimate_cost

Price a request before running it and compare models

get_usage

Estimated spend by period, model and tool; budgets remaining; running jobs

get_config

Active backend and why it was chosen, output directory, defaults, warnings

Every result includes the saved file's path, a gemini-media://files/<name> URI and its cost. You can pass the URI as an input to another tool. Clients that can't read the server's disk (for example over HTTP) can fetch the file with resources/read, for files up to 64 MB (larger upscales stay on the server's disk).

Skills

The skills/ directory contains Agent Skills that teach agents the full workflow for each media type: intent, prompt craft, model choice, cost checks, review and iteration. They cover interactive use as well as unattended runs.

Skill

For

gemini-image

Images: generation, editing, multi-reference composition, text rendering

gemini-video

Video: text/image-to-video, frame interpolation, reference ingredients, Omni editing, extension, async jobs

gemini-speech

Voiceovers, narration, two-speaker dialogue, voice and style selection

gemini-music

Clips and full songs with structure, lyrics and tempo

gemini-media-production

Multi-asset projects (storyboard → keyframes → video → voiceover → music → ffmpeg assembly) with a budget plan

gemini-upscale

Upscaling photos to 1K, 2K, 4K or 8K: one tile up to 4K, a grid of 4K tiles stitched together beyond that, with an optional fix pass for defects such as mismatched eyes. About $0.04 at 1K to $0.50–1.20 at 8K. It invents plausible detail rather than recovering it, so it is not for forensic or archival use

Plugin installs (Claude Code, Codex, Gemini CLI, VS Code) include the skills. To install them in any Agent Skills–compatible agent, run npx skills add mordor-forge/gemini-media-mcp, or copy the folders into .agents/skills/ or ~/.claude/skills/.

Models

Use an alias or a full model ID. Run gemini-media-mcp models for the built-in catalog with prices, or call list_models, which also applies your override file and, with live: true, checks what your key can use.

Media

Aliases (default first)

Image

nb2 (Nano Banana 2.1, default), pro (Nano Banana Pro: highest fidelity), nb2-lite (cheapest inputs)

Video

omni (Gemini Omni Flash, default on the Gemini API: prompt adherence, editing, extension to 40 s; Gemini API only), lite (cheapest Veo, default on Vertex AI), fast (Veo 4K, references, extension), standard (highest Veo quality)

Speech

tts (Gemini 3.8 Flash TTS), tts-lite, tts-2.5, tts-pro

Music

clip (30 s), full (Lyria 3.5 songs)

Veo on the Gemini API. Google is shutting down the Veo 3.1 previews (and the gemini-omni-flash-preview model) on the Gemini API on 2026-10-22. Until then lite, fast and standard still work there with a deprecation warning; after it the server uses omni instead and says so. Veo 3.1 stays available on Vertex AI, now called Gemini Enterprise Agent Platform (veo-3.1-*-generate-001): to keep using it, run the server against a Google Cloud project: GOOGLE_CLOUD_PROJECT plus gcloud auth application-default login, and GEMINI_MEDIA_BACKEND=vertex if an API key is also set (see Configuration).

Updating or adding a model without waiting for a release. Create a YAML file and point GEMINI_MEDIA_CATALOG at it. The server merges it with the built-in catalog by id and reloads it automatically:

defaults:
  video: fast
models:
  - id: veo-3.1-fast-generate-preview
    pricing: { perSecond: { 720p: 0.10, 1080p: 0.12, 4k: 0.30 } }
  - id: veo-4.0-generate-preview        # a brand-new model
    aliases: [veo4]
    pricing: { perSecond: { 720p: 0.50 } }

See internal/catalog/models.yaml for the full schema.

Configuration

Settings are layered: built-in defaults < config file < environment < flags. The config file lives at ~/.config/gemini-media-mcp/config.yaml on Linux, ~/Library/Application Support/gemini-media-mcp/config.yaml on macOS, %AppData%\gemini-media-mcp\config.yaml on Windows, or wherever GEMINI_MEDIA_CONFIG points. Unknown keys produce warnings instead of errors, and get_config shows where each setting came from.

Environment variable

Config key

Default

Purpose

GEMINI_API_KEY / GOOGLE_API_KEY / GEMINI_MEDIA_API_KEY

apiKey

–

Gemini API key (or Vertex express-mode key)

GEMINI_MEDIA_PROJECT / GOOGLE_CLOUD_PROJECT

project

–

Vertex AI project (Application Default Credentials)

GEMINI_MEDIA_LOCATION / GOOGLE_CLOUD_LOCATION / GOOGLE_CLOUD_REGION

location

per model

Vertex region; models not offered there use their catalog location

GOOGLE_GENAI_USE_VERTEXAI / GOOGLE_GENAI_USE_ENTERPRISE

–

–

true selects Vertex AI, false the Gemini API (same semantics as the Google SDKs)

GEMINI_MEDIA_BACKEND

backend

auto

auto, gemini-api or vertex

MEDIA_OUTPUT_DIR / GEMINI_MEDIA_OUTPUT_DIR

outputDir

~/generated_media

Where media is saved

GEMINI_MEDIA_STATE_DIR

stateDir

$XDG_STATE_HOME/gemini-media-mcp, else ~/.local/state/gemini-media-mcp (Linux) or the config directory

Spend ledger and video jobs

GEMINI_MEDIA_BUDGET_SESSION_USD / _DAILY_USD / _MONTHLY_USD

budget.*Usd

none

Spend caps (estimated)

GEMINI_MEDIA_CONFIRM_ABOVE_USD

budget.confirmAboveUsd

none

Calls above this need approvedCostUsd

GEMINI_MEDIA_IMAGE_MODEL / _VIDEO_MODEL / _SPEECH_MODEL / _MUSIC_MODEL / GEMINI_MEDIA_VOICE

defaults.*

catalog

Default models and voice (a model set here is the default on both backends; the server refuses to start if the backend in use does not offer it)

GEMINI_MEDIA_CATALOG

catalogFile

–

Catalog override file (hot-reloaded)

GEMINI_MEDIA_INPUT_DIRS

inputDirs

–

Extra directories inputs may be read from (HTTP mode)

GEMINI_MEDIA_ALLOW_ANY_INPUT_PATH

allowAnyInputPath

true on stdio, false on HTTP

Read input files from anywhere on disk

GEMINI_MEDIA_INLINE_PREVIEWS / GEMINI_MEDIA_PREVIEW_MAX_PIXELS

inlinePreviews / previewMaxPixels

true / 768

Attach a downscaled preview to image results, and its longest side

GEMINI_MEDIA_REQUEST_TIMEOUT_SECONDS

requestTimeoutSeconds

600

Timeout of each Google API request

GEMINI_MEDIA_MAX_VIDEO_WAIT_SECONDS

maxVideoWaitSeconds

600

Upper limit for waitSeconds on video tools

GEMINI_MEDIA_RETRY_ATTEMPTS

retry.attempts

4

Attempts for rate-limited (429) and unavailable (503) responses

GEMINI_MEDIA_LOG_LEVEL

logLevel

info

debug, info, warn or error (logs go to stderr)

GEMINI_MEDIA_TRANSPORT

transport

stdio

stdio or http

GEMINI_MEDIA_HTTP_ADDR / GEMINI_MEDIA_HTTP_TOKEN

http.addr / http.authToken

127.0.0.1:8765 / –

HTTP listen address and bearer token

–

http.path

/mcp

HTTP endpoint path

GEMINI_MEDIA_HTTP_ALLOWED_ORIGINS

http.allowedOrigins

–

Extra trusted browser origins, comma-separated

GEMINI_MEDIA_HTTP_STATEFUL

http.stateful

false

Keep per-client sessions (only for legacy 2025-11-25 clients that need them)

How the backend is chosen:

  1. An explicit backend setting wins.

  2. Otherwise the SDK switches GOOGLE_GENAI_USE_ENTERPRISE and GOOGLE_GENAI_USE_VERTEXAI decide.

  3. Otherwise an API key selects the Gemini API, even if GOOGLE_CLOUD_PROJECT is set in your shell for other tools.

  4. Otherwise a project selects Vertex AI.

On Vertex, an API key without a project uses express mode, which does not support video.

Spend and budgets

Google doesn't return costs, so the server computes them from its price table and the token usage the API reports. Every call records an estimate before it runs and the reconciled cost afterwards. Failed and safety-blocked generations count as $0. A response that used tokens but returned no media (for example MAX_TOKENS) is charged for those tokens.

  • Results include cost {estimatedUsd, usd, basis}. get_usage and gemini-media-mcp usage summarize spend. The ledger is a plain JSONL file in the state directory.

  • Budgets are enforced before each call, across concurrent calls and across several server processes sharing a state directory (in-flight calls hold their estimate under a file lock).

  • With GEMINI_MEDIA_CONFIRM_ABOVE_USD=1, an expensive call (for example a $3.20 Veo clip) comes back as a [confirmation] error. The agent asks you, then retries with approvedCostUsd.

  • These figures are estimates. For a hard stop, also set a spend cap in AI Studio or a budget in Cloud Billing.

HTTP mode

GEMINI_API_KEY=... gemini-media-mcp serve --transport http                 # http://127.0.0.1:8765/mcp
GEMINI_MEDIA_HTTP_TOKEN=secret gemini-media-mcp serve --transport http --http-addr 0.0.0.0:8765
claude mcp add --transport http gemini-media http://127.0.0.1:8765/mcp --header "Authorization: Bearer secret"
  • HTTP mode is stateless Streamable HTTP, which MCP 2026-07-28 requires; older clients still work.

  • The server protects against DNS rebinding and cross-origin requests.

  • It refuses to listen on a non-loopback address without a token.

  • It only reads input files from the output directory or GEMINI_MEDIA_INPUT_DIRS (unless GEMINI_MEDIA_ALLOW_ANY_INPUT_PATH=true).

  • GET /healthz reports status.

Development

Paid live E2E tests are run locally with your own API key. CI runs the free checks and compiles/vets the E2E tests, but never executes live generation, including after merges to main or on manual workflow runs.

go build ./...
go test -race ./...
golangci-lint run
python3 scripts/validate-skills.py skills
GEMINI_MEDIA_E2E=1 GEMINI_API_KEY=... go test -tags=e2e ./internal/media/ -run E2E -v -timeout 30m   # live, costs cents
# add GEMINI_MEDIA_E2E_VIDEO=1 for the video test (~$0.20), GEMINI_MEDIA_E2E_OMNI=1 for the Omni clip + edit (~$0.30),
# GEMINI_MEDIA_E2E_UPSCALE=1 for a small tiled upscale (~$0.20),
# GEMINI_MEDIA_E2E_OUTPUT_DIR=./e2e-out to keep the files

License

Apache-2.0

Available Tools

14 tools
edit_imageEdit imageA

Change an existing image with an instruction (add/remove/replace elements, restyle, relight, change aspect ratio, fix text) while keeping everything else. Accepts extra reference images to insert or match. Say what must stay unchanged. Saves a new file; the original is kept.

Inputs: image (required), prompt (required), model, imageSize, +4 more. Returns: cost, text, files, model, +2 more

edit_videoEdit videoA

Change an existing clip with an instruction (add, remove or replace objects, restyle, relight, change the background) with Gemini Omni Flash, keeping everything else. Pass the jobId of a finished clip (Omni clips are edited in conversation) or a video file of at most 10 s. Asynchronous like generate_video; about $0.10 per second of video at 720p.

Inputs: prompt (required), jobId, model, video, +5 more. Returns: cost, next, error, files, +6 more

estimate_costEstimate costA
Read-onlyIdempotent

Estimate the cost of an image, video, speech or music request before running it, optionally comparing all models; also reports remaining budget and whether approval is needed.

Inputs: mediaType (required), text, count, model, +6 more. Returns: note, model, estimate, warnings, +4 more

extend_videoExtend videoA

Continue a completed clip from its end: omni adds up to 10 s (40 s total, keeping characters and audio coherent); Veo fast/standard add about 7 s (720p, up to 148 s, within 2 days). Asynchronous like generate_video.

Inputs: jobId (required), prompt (required), seed, outputName, +3 more. Returns: cost, next, error, files, +6 more

generate_imageGenerate imageA

Create images from a text prompt, optionally guided by up to 14 reference images (subjects, products, style). Default model nb2 (Nano Banana 2.1, $0.04 per 1K image); pro for the densest scenes and final renders ($0.15); nb2-lite for bulk drafts. Returns saved files with URIs you can pass to edit_image, generate_video (image) or other tools.

Inputs: prompt (required), count, model, imageSize, +5 more. Returns: cost, text, files, model, +2 more

generate_musicGenerate musicA

Compose music with Lyria: 30-second clips (clip, $0.04) or full songs of a few minutes with vocals and lyrics (full, $0.08). Control genre, mood, instruments, tempo and structure in the prompt; returns lyrics/structure text when available.

Inputs: prompt (required), bpm, model, format, +6 more. Returns: cost, file, model, lyrics, +2 more

generate_speechGenerate speechA

Turn text into natural speech (WAV) with one voice, or a dialogue between two speakers. Control delivery with style. About $0.01-0.02 per minute of audio. For podcasts, voiceovers, narration and dialogue.

Inputs: text, model, style, voice, +6 more. Returns: cost, file, model, voices, +2 more

generate_videoGenerate videoA

Start a video clip with native audio from a text prompt, optionally from a first frame, first+last frames, or reference images. Default omni (Gemini Omni Flash: 3-10s, cheap 360p drafts up to 4K, up to 10 references). On Vertex AI the default is Veo lite; fast/standard add Veo 4K and ingredients. Veo is leaving the Gemini API (list_models has the date). estimate_cost prices any option. Asynchronous: returns a jobId; then call get_video.

Inputs: prompt (required), seed, image, model, +11 more. Returns: cost, next, error, files, +6 more

get_configGet configurationA
Read-onlyIdempotent

Show the active backend and how it was chosen, output directory, default models, budgets, input-file policy and configuration warnings. Use it to troubleshoot credentials or missing files.

Returns: budget, backend, project, version, +15 more

get_usageGet usage and spendA
Read-onlyIdempotent

Report estimated spend for this session, today, this month or all time, broken down by model and tool, with budget remaining, recent calls and running video jobs.

Inputs: period, recent. Returns: note, extra, budget, period, +3 more

get_videoGet video jobA
Idempotent

Check a video job and wait for it (default up to 45s). When the job completes, the video is downloaded and returned; calling again is safe and returns the same files.

Inputs: jobId (required), waitSeconds. Returns: cost, next, error, files, +6 more

list_modelsList modelsA
Read-onlyIdempotent

List current models per media type with aliases, status (GA/preview/deprecated), prices and a short guide to when to use each. detail: true adds supported aspect ratios, sizes, durations and voices; live: true checks what your API key can actually call.

Inputs: live, detail, mediaType, includeInactive. Returns: models, backend, warnings, uncatalogued, +1 more

stitch_tilesStitch upscaled tilesA

Upscale step 3: align each edited tile from tile_image with the image, match its broad color, blend the overlaps and save one large PNG (default 8192 px long edge). Free and local. Reports tiles it rejected (their area keeps the prior pixels) and returns a preview plus 100% crops of the seams to inspect.

Inputs: job (required), tiles (required), details, feather, +2 more. Returns: file, next, pass, tiles, +5 more

tile_imageTile image for upscalingA

Upscale step 1: cut an image into crops shaped to the edit model's aspect ratios. longEdge sets the target (1K-16K, default 8K); with grid and imageSize omitted it picks the cheapest plan that covers it (one tile up to about 4K, a 2x2-4x4 grid beyond). regions re-render faces or text in a later pass. Free and local; reports the edit cost. Step 2: edit_image each crop as the result says. Step 3: stitch_tiles. Detail is invented, not recovered.

Inputs: image (required), grid, model, padding, +5 more. Returns: job, cost, grid, mode, +12 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 14 tools

    Disambiguation4/5

    Most tools have distinct resource+action purposes (generate vs edit vs extend for each media type; tile/stitch form a clear two-step pipeline). A few boundaries are softer: estimate_cost vs get_usage both report spend, and get_config vs list_models both expose backend/model info, but descriptions differentiate them adequately.

    Naming Consistency5/5

    All 14 tools follow a strict snake_case verb_noun pattern (generate_image, edit_video, extend_video, get_video, list_models, stitch_tiles). No mixing of camelCase or inconsistent verb styles.

    Tool Count5/5

    14 tools is well-scoped for a multi-media generation server covering image, video, speech and music plus cost/utilization helpers. Each tool occupies a distinct slot in the lifecycle rather than duplicating capability.

    Completeness4/5

    The surface covers generation, editing, extension, upscaling and cost/usage introspection across all four media types, with async job polling handled via get_video. Minor gaps remain, e.g. no explicit audio-video muxing or file management operations, but core workflows have no dead ends.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers