gemini-vision-mcp
This server lets you send local files or URL resources to Gemini for description/extraction and manage a persistent Live session.
Describe a single local file (image, audio, video, or text) with a custom prompt.
Describe multiple local files in one request, either same media type or mixed media types.
Describe one or multiple URL resources, either same media type or mixed media types.
Use alias tools such as
from_file,from_files,from_resource, andfrom_resources.Reset the Gemini Live session with
new_vision(loses conversation history).Compact conversation history with
compactorcompact=trueto reduce tokens while preserving context.Inspect token usage, TPM, and rate-limit status with
gemini_usage.Run the server over stdio or Streamable HTTP with bearer auth, rate limiting, SSRF protections, and session controls.
Provides tools for describing video, image, audio, and text using the Gemini Live API, including single or multiple local files, URL resources, persistent sessions, and session management.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gemini-vision-mcp Describe the scene in /path/to/image.jpg"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gemini-vision-mcp
MCP server for describing video, image, audio, and text using the Gemini Live API.
Uses a persistent WebSocket session (Google GenAI Live API via @google/genai) to describe media content through the Model Context Protocol TypeScript SDK.
Supports both stdio and Streamable HTTP transports (select with --transport).
Requirements
Node.js 18+
pnpm 8+
Google API key with Gemini access
Related MCP server: Gemini MCP Server
Install
Install the published package directly from GitHub (the prepare script
builds dist/ automatically, so no manual build step is needed):
npm install -g github:Niruchie/gemini-vision-mcpThen run it as a command:
gemini-vision-mcpConfiguration
Copy .env.example to .env and fill in your API key:
cp .env.example .envVariable | Default | Description |
| - | Required. Your Google Gemini API key |
|
| Gemini Live model to use |
|
| Tokens per minute limit for auto-refresh |
|
| Rate limit window in seconds |
|
| Max requests per rate window |
|
| HTTP transport port |
|
| HTTP transport host |
| - | Bearer token for |
| loopback + | Extra |
| - | Exact |
| - |
|
|
| Concurrent MCP sessions per process; further sessions get HTTP 429 |
|
| Idle session lifetime; |
|
| Max bytes read from a local file (64 MiB) |
|
| Max bytes accepted from a fetched URL (64 MiB) |
| - |
|
See Security for what these do and why the defaults are strict.
Usage
Stdio (default):
node dist/index.js
# or
pnpm startHTTP (Streamable HTTP + /health):
export MCP_AUTH_TOKEN=$(openssl rand -hex 32) # required when HOST is not loopback
node dist/index.js --transport http --port 3000
# or
pnpm start:httpFlags (--transport stdio|http, --port, --host, --auth-token) override the
MCP_TRANSPORT, PORT, HOST, MCP_AUTH_TOKEN env vars.
The server refuses to start when it is bound to a non-loopback address and no
token is configured (use MCP_ALLOW_INSECURE_HTTP=1 to override deliberately).
MCP Client Configuration
Stdio (e.g. opencode opencode.json):
{
"mcp": {
"gemini-vision": {
"environment": {
"GOOGLE_API_KEY": "your-api-key",
"GEMINI_MODEL": "gemini-3.1-flash-live-preview",
"RATE_LIMIT_WINDOW_SECONDS": "60",
"RATE_LIMIT_REQUESTS": "10"
},
"enabled": true,
"type": "local",
"cwd": ".",
"command": ["node", "dist/index.js"]
}
}
}HTTP:
{
"mcp": {
"gemini-vision": {
"enabled": true,
"type": "remote",
"url": "http://127.0.0.1:3000/mcp",
"headers": {
"Authorization": "Bearer ${MCP_AUTH_TOKEN}"
}
}
}
}Tools
Tool | Description |
| Describe a single file (image, audio, video, or text) |
| Alias for |
| Describe multiple files in one request |
| Alias for |
| Multiple files with different media types |
| Alias for |
| Describe a URL resource |
| Alias for |
| Describe multiple URL resources |
| Alias for |
| Multiple URLs with different media types |
| Alias for |
| Force a fresh Gemini Live session (loses context) |
| Summarize history via model, reconnect with summary |
| Report current token usage and TPM status |
Parameters
type: Media category -text,image,audio, orvideoprompt: Instructions to the model (what to describe/extract)path: Local file path (file tools)resource: URL to fetch (resource tools)compact: If true, auto-compact history after this request (vision tools only)
Example: describe an image
vision_from_file(type="image", path="/path/to/photo.jpg", prompt="Describe the scene in detail")Example: extract text from a screenshot
vision_from_file(type="image", path="/path/to/screenshot.png", prompt="Extract all visible text")Example: batch describe images
vision_from_files(type="image", paths=["/a.jpg", "/b.jpg", "/c.jpg"], prompt="Describe each image")Example: describe a URL resource
vision_from_resource(type="image", resource="https://example.com/photo.png", prompt="What is in this image?")Session management
The server maintains a conversation history across tool calls and uses a two-tier TPM management strategy:
70% TPM - Auto-compaction: the model summarizes the conversation history, then reconnects with the summary as context. History shrinks, session continues.
75% TPM - Hard refresh: reconnects with whatever compacted history exists. Use
new_visionto reset completely (loses all context).
You can also trigger compaction manually:
compact()Or pass compact=true to any vision tool to compact after that request:
vision_from_file(type="image", path="photo.jpg", prompt="Describe this", compact=true)Call new_vision to force a clean reset (no history carried over).
Call gemini_usage to inspect current token consumption and rate limit status.
Docker
docker build -t gemini-vision-mcp:0.1.0 .
docker run --rm -p 3000:3000 \
-e GOOGLE_API_KEY=your-api-key \
-e MCP_AUTH_TOKEN=$(openssl rand -hex 32) \
gemini-vision-mcp:0.1.0The image defaults to HTTP transport on port 3000 (/mcp, /health) bound to
0.0.0.0, so MCP_AUTH_TOKEN is mandatory - the container exits at startup
without it. Override the command for stdio:
docker run --rm -i gemini-vision-mcp:0.1.0 node dist/index.js.
Helm
helm install gemini-vision ./helm/gemini-vision-mcp \
--set apiKey.value=your-api-key
# or reference an existing secret:
helm install gemini-vision ./helm/gemini-vision-mcp \
--set apiKey.existingSecret=my-secret \
--set authToken.existingSecret=my-auth-secretThe chart generates a random MCP_AUTH_TOKEN when authToken.value is empty and
keeps it across upgrades; helm install prints the command to read it. The chart
also runs the pod as non-root with a read-only root filesystem, drops all
capabilities, keeps the Service internal (ClusterIP) and allowlists the service
DNS names in the Host header check.
Key values: image.repository/tag, transport (http creates a
Service; stdio skips it), config.model, config.tpmLimit,
config.rateLimitRequests, config.rateLimitWindowSeconds, resources,
probes, authToken, allowedHosts, allowedOrigins,
podSecurityContext, containerSecurityContext.
Security
What the server protects against, and what it deliberately leaves to you:
Area | Behavior |
HTTP auth |
|
DNS rebinding |
|
SSRF | The URL tools refuse non- |
Resource exhaustion | Bodies are capped at 4 MiB per JSON-RPC request, URL responses and local files at 64 MiB ( |
Rate limiting | The sliding-window limiter is shared across HTTP sessions, so opening a new session cannot reset it. |
Error handling | Internal error details are logged server-side only; clients get a generic message plus a correlation |
Credentials |
|
What is not covered - read before exposing this server:
vision_from_filereads whatever the process can read, and the URL tools fetch whatever the network allows. Anyone who can call/mcpgets that same access (file read + reachable HTTP endpoints), so treat the bearer token like a shell credential: no public ingress, no shared tokens, keep it behind a private network.Path and URL access is intentionally unrestricted (that is the point of the tools). There is no per-directory sandbox; run it in a container or under a dedicated user if you need one.
The token is a shared secret with no rotation or expiry: rotate it by changing
MCP_AUTH_TOKENand restarting, and restart pods after updating the Secret.The rate limiter lives in process memory. With
replicaCount > 1each pod keeps its own window, so the effective limit isRATE_LIMIT_REQUESTSmultiplied by replicas. Use a single replica or a shared store (Redis) if you need a global limit.Media sent through the tools leaves the machine for the Gemini API - do not feed it anything you would not send to Google.
Testing
pnpm test # unit tests (vitest, no API key or network needed)
pnpm test:live # live integration test against the real Gemini Live APIUnit tests use vitest plus the MCP SDK's InMemoryTransport (there is no
dedicated MCP unit-testing tool, so this is the standard approach: an
in-memory client talks to the real server with stubbed env). They cover the
rate limiter, token-usage accounting, media helpers, tool registration, the
config://gemini-vision resource, missing-key handling, and rate-limit
enforcement - all hermetic via vi.stubEnv + vi.resetModules().
tests/http.test.ts boots the real Express app on an ephemeral port and checks
the transport security: bearer auth (missing/wrong/valid), fail-closed startup
on a public interface, Host and Origin rejection, JSON error responses, and
that /health stays public. tests/helpers.test.ts additionally covers the SSRF
blocklist, redirect re-validation and the size caps (no network needed).
tests/live.test.ts boots dist/ over stdio and exercises every tool in one
session: all six file tools (plus aliases) against downloaded fixtures, a
new_vision reset asserting zeroed usage, all six URL tools (plus aliases),
length-mismatch and missing-file error paths, compact, and gemini_usage.
It raises RATE_LIMIT_REQUESTS to 100 for the server subprocess so the
default 10 req/60s limiter doesn't interfere. Costs roughly 15k input tokens.
Architecture
src/server.ts- MCP server, tool registration, rate limitingsrc/gemini-live.ts- Persistent Gemini Live WebSocket client with auto-reconnect, history tracking, and self-compactionsrc/rate-limiter.ts- Sliding window rate limitersrc/http.ts- Streamable HTTP transport, bearer auth, host/origin validation, error sanitizationsrc/index.ts- CLI entry,--transport stdio|httpsrc/tool/- Tool implementations (compact, file, files, files_mixed, gemini_usage, new_vision, resource, resources, resources_mixed) plus_helpers.ts(mime detection, URL/file size caps and SSRF guards)src/event/- Background TPM monitoring
License
Licensed under the Apache License 2.0. See NOTICE for the copyright holder.
The software is provided "as is", without warranty or condition of any kind, and the author is not liable for any damages or losses arising from its use, misuse or modification - see Section 7 (Disclaimer of Warranty) and Section 8 (Limitation of Liability) of the license text.
If you are modifying it and want others to know, Section 4(b) requires you to carry prominent notices stating that you changed the files.
Found a security problem? Read SECURITY.md before opening an issue.
Available Tools
15 toolscompactA
Compact conversation history and reconnect.
Summarizes older turns, keeps recent ones verbatim, and replays into a fresh Gemini Live session so context carries over. Use instead of new_vision when you want to preserve context.
Inputs: no named parameters. Returns: result
from_fileC
Alias for vision_from_file — describe a single file using Gemini.
Inputs: path (required), type (required), prompt (required), compact. Returns: result
from_filesC
Alias for vision_from_files — describe multiple files using Gemini.
Inputs: type (required), paths (required), prompt (required), compact. Returns: result
from_files_mixedC
Alias for vision_from_files_mixed — describe mixed-type files using Gemini.
Inputs: paths (required), types (required), prompt (required), compact. Returns: result
from_resourceC
Alias for vision_from_resource — describe a URL using Gemini.
Inputs: type (required), prompt (required), resource (required), compact. Returns: result
from_resourcesC
Alias for vision_from_resources — describe multiple URLs using Gemini.
Inputs: type (required), prompt (required), resources (required), compact. Returns: result
from_resources_mixedC
Alias for vision_from_resources_mixed — describe mixed-type URLs using Gemini.
Inputs: types (required), prompt (required), resources (required), compact. Returns: result
gemini_usageA
Get current Gemini API usage statistics.
Returns token usage stats including input/output tokens and rate limit status.
Inputs: no named parameters. Returns: result
new_visionA
Force a fresh Gemini Live session.
Call this to reset the connection if it's stale or returns errors. Existing conversation history is lost.
Inputs: no named parameters. Returns: result
vision_from_fileC
Describe a single file (image, audio, video, or text) using Gemini.
Inputs: path (required), type (required), prompt (required), compact. Returns: result
vision_from_filesC
Describe multiple files in one Gemini session.
Inputs: type (required), paths (required), prompt (required), compact. Returns: result
vision_from_files_mixedA
Describe multiple files of mixed types in one Gemini session.
Inputs: paths (required), types (required), prompt (required), compact. Returns: result
vision_from_resourceC
Describe a URL resource using Gemini.
Inputs: type (required), prompt (required), resource (required), compact. Returns: result
vision_from_resourcesC
Describe multiple URL resources in one Gemini session.
Inputs: type (required), prompt (required), resources (required), compact. Returns: result
vision_from_resources_mixedA
Describe multiple URL resources of mixed types in one Gemini session.
Inputs: types (required), prompt (required), resources (required), compact. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
The 10 vision/from_* tools are essentially duplicate or near-duplicate aliases of each other (vision_from_file vs from_file, vision_from_files vs from_files, etc.), creating massive ambiguity. An agent cannot reliably distinguish which tool to pick when 12 of 15 tools describe the same core operation of 'describe files/resources with Gemini'.
There is a somewhat consistent pattern within the vision_from_* family (file/files/files_mixed, resource/resources/resources_mixed), but the alias tools (from_file, from_files, etc.) and the duplicate prefix 'vision_from_' broken by short aliases create two inconsistent naming conventions. The mix of descriptive prefixes with abbreviated aliases, plus session management tools (new_vision, compact) that don't follow the pattern, makes naming inconsistent overall.
15 tools is within the borderline range, but roughly two-thirds of them are redundant aliases of the same 5-6 core operations. The effective distinct tool surface is only about 5 unique operations inflated to 15, making the count feel padded rather than well-scoped.
The core input variants (single vs multiple, file vs resource, mixed types) are covered, and session management (reset, compact, usage stats) is present. However, there are no tools for more advanced capabilities like providing prompts/instructions to the vision model, and the heavy alias duplication obscures whether genuinely useful operations are missing.
Related MCP Connectors
MCP server for Wan AI video generation
MCP server for Google Veo AI video generation
MCP server for Grok Imagine AI video generation
MCP server for Hailuo (MiniMax) AI video generation
Related MCP Servers
- AlicenseAqualityFmaintenanceProduction-grade MCP server for image and video understanding and generation across Gemini, OpenAI, and Grok.587 PyPI4Apache 2.0
- FlicenseNot gradedqualityDmaintenanceMCP server that connects Claude Desktop to Google Gemini, enabling multimodal analysis with file attachments (video, image, audio, PDF).-
- AlicenseAqualityCmaintenanceMCP server for Google's Gemini API, enabling text, image, video, speech, embeddings, and deep research capabilities through a single tool set.10MIT
- AlicenseNot gradedqualityDmaintenanceRemote MCP server that exposes Google Gemini's text, image, video (Veo), and audio transcription capabilities as tools any MCP client can call directly.ISC