gemini-vision-mcp
MCP server for describing video, image, audio, and text using the Gemini 3.1 Flash Live API with persistent WebSocket sessions.
README
gemini-vision-mcp
MCP server for describing video, image, audio, and text using the Gemini 3.1 Flash Live API.
Uses a persistent WebSocket session (Google GenAI Live API) to describe media content through FastMCP.
Requirements
- Python 3.11+
- Google API key with Gemini access
Install
uv pip install gemini-vision-mcp
Or run directly with uvx:
uvx gemini-vision-mcp
Configuration
Copy .env.example to .env and fill in your API key:
cp .env.example .env
| Variable | Default | Description |
|---|---|---|
GOOGLE_API_KEY |
— | Required. Your Google Gemini API key |
GEMINI_MODEL |
gemini-3.1-flash-live-preview |
Gemini model to use (More models to be tested.) |
GEMINI_TPM_LIMIT |
4000000 |
Tokens per minute limit for auto-refresh |
RATE_LIMIT_WINDOW_SECONDS |
60 |
Rate limit window in seconds |
RATE_LIMIT_REQUESTS |
10 |
Max requests per rate window |
Usage
Run with uvx:
uvx --no-cache --from . gemini-vision-mcp
This project uses uvx for running and venv for development.
MCP Client Configuration
Add to your MCP client (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": [
"uvx",
"--no-cache",
"--from",
".",
"gemini-vision-mcp"
]
}
}
}
Tools
| Tool | Description |
|---|---|
vision_from_file |
Describe a single file (image, audio, video, or text) |
from_file |
Alias for vision_from_file |
vision_from_files |
Describe multiple files in one request |
from_files |
Alias for vision_from_files |
vision_from_files_mixed |
Multiple files with different media types |
from_files_mixed |
Alias for vision_from_files_mixed |
vision_from_resource |
Describe a URL resource |
from_resource |
Alias for vision_from_resource |
vision_from_resources |
Describe multiple URL resources |
from_resources |
Alias for vision_from_resources |
vision_from_resources_mixed |
Multiple URLs with different media types |
from_resources_mixed |
Alias for vision_from_resources_mixed |
new_vision |
Force a fresh Gemini Live session (loses context) |
compact |
Summarize history via model, reconnect with summary |
gemini_usage |
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.
Architecture
src/server.py— FastMCP server, tool registration, rate limitingsrc/gemini_live.py— Persistent Gemini Live WebSocket client with auto-reconnect, history tracking, and self-compactionsrc/rate_limiter.py— Sliding window rate limitersrc/tool/— Tool implementations (compact, file, files, files_mixed, gemini_usage, new_vision, resource, resources, resources_mixed)src/event/— Background TPM monitoring
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。