Vision MCP Server
A Model Context Protocol server that provides text-only LLMs with visual capabilities through Z.AI-compatible vision tools, routing requests across multiple providers with automatic fallback.
README
Vision MCP Server
A Vision MCP Server that gives text-only LLMs / coding agents visual capabilities over the Model Context Protocol.
The server exposes Z.AI-compatible vision tools (analyze_image,
extract_text_from_screenshot, ui_diff_check, ...) and routes every request
through a configurable chain of visual providers (AGY, Codex, Gemini API,
OpenCode) with automatic fallback. Provider, model, API key and fallback order
are server policy — the LLM never sees or chooses them.
Why a Vision MCP?
Most coding agents / text-only LLMs cannot "see" screenshots, error traces, UI mockups or diagrams. This server acts as their eyes:
Text-only LLM
│ MCP
▼
Vision MCP Server
├── Z.AI-compatible Vision Tools
├── Specialized Prompt Layer
├── Media / Workspace Layer
├── Structured JSON Layer
└── Provider Router (AGY → Codex → Gemini → OpenCode)
Features
- 8 Z.AI-compatible vision tools + 2 aliases.
- Provider-neutral tools: no
provider/model/api_key/workdir/timeoutin tool schemas — those are server config. - Provider Router with configurable order and fallback policy.
- Unified structured JSON output (observations, texts, elements, bbox).
- Local paths and HTTP(S) URLs;
file://rejected. - Per-task isolated workspaces; automatic cleanup.
- CLI-native images (Codex
-i, OpenCode--file) and AGY workspace staging with vision-capability detection. - Gemini API via
google-genai. vision-mcp doctorenvironment inspection +--probevision smoke test.- No ACP / no transport abstraction in v1.
Requirements
- Python 3.11+
- macOS / Linux / Windows
Installation
pip install -e .
Or with a virtualenv + uv:
uv venv --python 3.11 .venv
source .venv/bin/activate
uv pip install -e ".[dev]" # dev = pytest, pytest-asyncio, Pillow (for doctor --probe)
Quick start
# Copy the example config and edit it to suit your machine.
cp config.example.yaml ~/.config/vision-mcp/config.yaml
# Run as an MCP stdio server
vision-mcp --config ~/.config/vision-mcp/config.yaml
# Or
python -m vision_mcp --config ~/.config/vision-mcp/config.yaml
MCP client configuration
{
"mcpServers": {
"vision": {
"command": "vision-mcp",
"args": ["--config", "/Users/me/.config/vision-mcp/config.yaml"],
"env": { "GEMINI_API_KEY": "..." }
}
}
}
Configuration
Configuration priority: CLI argument > environment variable > config file > built-in default.
version: 1
providers:
order: [agy, codex, gemini, opencode]
agy:
enabled: true
command: agy
model: null
codex:
enabled: true
command: codex
model: null
gemini:
enabled: true
model: null
api_key_env: GEMINI_API_KEY
opencode:
enabled: true
command: opencode
model: null
runtime:
workdir: null # null => temporary dir per task
timeout: 120
max_concurrency: 2
fallback:
enabled: true
on:
- command_not_found
- not_authenticated
- api_key_missing
- quota_exhausted
- unsupported_media
- timeout
- temporary_failure
media:
max_image_mb: 20
max_video_mb: 8
download_timeout: 30
max_download_mb: 32
logging:
level: INFO
Provider order
The router tries providers in the configured order and falls back on failure.
Default: agy → codex → gemini → opencode.
Not fallback-eligible by default: invalid_input, invalid_model,
config_error. The fallback.on list is the final authority.
Provider model
Each provider's model is set in config and used automatically on fallback — there is no cross-provider model namespace to manage.
providers:
agy: { model: gemini-xxx }
codex: { model: gpt-xxx }
gemini: { model: gemini-xxx }
opencode: { model: google/gemini-xxx }
Set a model to null to let the provider use its own default.
Gemini API key
API keys are never tool arguments. Resolution order:
VISION_MCP_GEMINI_API_KEY
> config.providers.gemini.api_key_env (the env var it names)
> GEMINI_API_KEY
For compatibility a plain api_key may be placed in the config file; it is
stored as a SecretStr, never printed, never dumped, never returned in MCP
responses, and never included in exceptions. Prefer the environment variable.
Environment variables
VISION_MCP_CONFIG config file path
VISION_MCP_WORKDIR runtime workdir
VISION_MCP_TIMEOUT runtime timeout (s)
VISION_MCP_MAX_CONCURRENCY max concurrency
VISION_MCP_AGY_COMMAND agy executable
VISION_MCP_AGY_MODEL agy model
VISION_MCP_CODEX_COMMAND codex executable
VISION_MCP_CODEX_MODEL codex model
VISION_MCP_GEMINI_MODEL gemini model
VISION_MCP_GEMINI_API_KEY gemini API key
GEMINI_API_KEY gemini API key (fallback)
VISION_MCP_OPENCODE_COMMAND opencode executable
VISION_MCP_OPENCODE_MODEL opencode model
VISION_MCP_LOG_LEVEL ERROR | WARNING | INFO | DEBUG
Workdir
With runtime.workdir: null (default), every task gets a brand-new temporary
directory that is cleaned up on completion. With a project workdir configured,
task media is staged under <workdir>/.vision-mcp/<uuid>/ and removed after.
User files are never modified or deleted.
Media limits
Images: png/jpg/jpeg/webp/gif/bmp/tiff (default max_image_mb: 20). Videos:
mp4/mov/m4v (Z.AI-compatible default max_video_mb: 8). Remote downloads are
bounded by timeout, size and a redirect limit, and validated by MIME type.
Tools
| Tool | Purpose |
|---|---|
ui_to_artifact |
Convert a UI screenshot into code / prompt / spec / description |
extract_text_from_screenshot |
Verbatim OCR of code / terminal / config / docs |
diagnose_error_screenshot |
Diagnose error / stack trace / root cause / fix |
understand_technical_diagram |
Understand architecture / flowchart / UML / ER diagrams |
analyze_data_visualization |
Analyze charts: trends, anomalies, comparisons |
ui_diff_check |
Compare EXPECTED vs ACTUAL UI for visual regression |
analyze_image |
General visual analysis |
analyze_video |
Video analysis (mp4/mov/m4v) |
Aliases share the same implementations: image_analysis → analyze_image,
video_analysis → analyze_video.
Structured output
Every provider's result is normalized into one schema and wrapped in a standard envelope:
{
"provider": "codex",
"model": "gpt-xxx",
"result": {
"summary": "Short visual summary",
"answer": "Direct answer",
"observations": [{ "type": "text", "text": "...", "confidence": 0.95 }],
"texts": [{ "text": "visible text", "bbox": [100, 100, 900, 200], "confidence": 0.98 }],
"elements": [{ "label": "Build button", "type": "ui_element", "bbox": [700, 20, 820, 70], "confidence": 0.93 }],
"warnings": []
},
"meta": {
"duration_ms": 4812,
"fallbacks": [],
"usage": { "input_tokens": null, "output_tokens": null }
}
}
bbox is normalized to 0..1000 as [x_min, y_min, x_max, y_max]. When a
value can't be determined, providers do not guess — they omit it and add a
warning.
Doctor
vision-mcp doctor
vision-mcp doctor --probe # also runs a real AGY vision smoke test (needs Pillow)
vision-mcp --version
doctor never prints API key contents.
Provider detection
- AGY:
agy -p "<prompt>" --output-format json. Images are staged into the workspace and read natively via--add-dir(relative path reference). AGY's vision capability is probed once per process; if headless AGY auto-denies a tool permission it needs to read the image, that request raisesunsupported_mediaand falls back, while later requests still get a real AGY try. - Codex:
codex exec -i <img> ... --output-schema ... -s read-only. Images passed natively; read-only sandbox enforced. - Gemini:
google-genai, structured JSON, multi-image, configured model. - OpenCode:
opencode run --format json, images via--file, JSON event stream parsed for the final assistant result.
AGY non-determinism: AGY reads workspace images natively via
--add-dir. However, as of AGY CLI 1.1.x, headless mode is non-deterministic — a run may intermittently need aread_file/commandtool permission that headless mode auto-denies. When that happens the server detects it and transparently falls back to the next provider.vision-mcp doctor --probereports the capability without failing the server.
Security
The server only LOOK / READ / UNDERSTAND / COMPARE / ANALYZE — it never
EDIT / BUILD / EXECUTE / MODIFY. Codex runs in a read-only sandbox; AGY and
OpenCode are never launched with dangerous auto-approval. API keys are redacted
from all logs and responses.
Development
python -m pytest
Tests cover config, router, workspace, media, all four providers (subprocess /
genai mocked), Z.AI tool-schema compatibility, and an MCP tools/list +
tools/call smoke test.
Troubleshooting
agyfalls back to codex for images — AGY reads workspace images via--add-dir, but headless mode is non-deterministic and may intermittently auto-deny a tool permission. That is expected; the server falls back transparently. Runvision-mcp doctor --probeto exercise AGY directly.- Nothing responds — no provider is
enabled. Enable providers in config. - Gemini not used — an API key is required; see "Gemini API key".
- Codex blocks on stdin — the server always closes stdin for CLI providers.
- stdout corruption — all logs go to stderr; stdout is reserved for MCP.
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。