opencode-openai-vision-mcp
Provides image/vision support for OpenCode by routing images to any OpenAI-compatible endpoint, enabling paste-and-ask screenshot workflows.
README
opencode-openai-vision-mcp
A tiny MCP server that gives OpenCode (and any other MCP client) working image/vision support through any OpenAI-compatible endpoint — for example an OmniRoute or LiteLLM gateway, or OpenAI itself.
It reads an image file from disk, sends it to a vision-capable model as an
image_url content block, and returns the model's text description.
Why this exists
OpenCode currently cannot send image attachments to vision models served through a
custom OpenAI-compatible provider (@ai-sdk/openai-compatible). The attachment is
dropped before it reaches the model, and the assistant replies with something like:
this model does not support image input
This is an OpenCode adapter bug, tracked upstream in
anomalyco/opencode#20802
(fix PRs #26826 /
#21627 were not merged at the time
of writing). The underlying model and gateway are usually fine — a direct
/chat/completions call with image_url works; only OpenCode's conversion is broken.
This project is a workaround: instead of relying on OpenCode's native image path, it routes images through an MCP tool that you fully control.
How it works
OpenCode (you paste a screenshot)
└─ opencode-vision plugin intercepts the image inside OpenCode,
(separate project, see below) saves it to a temp file, and rewrites the
message to "call local_vision with this path"
└─ local_vision (THIS server) reads the file, base64-encodes it, and POSTs
it as image_url to an OpenAI-compatible endpoint
└─ your gateway/model e.g. OmniRoute -> any vision model
returns a text description back to OpenCode
This is a describe-then-reason approach: a vision model looks at the image and returns text; your main model works from that text. It is not native multimodality, but it restores the "paste a screenshot and ask" workflow.
Prerequisites
- Node.js >= 18
- A vision-capable model reachable via an OpenAI-compatible
/chat/completionsendpoint (OmniRoute, LiteLLM, OpenAI, etc.). - The opencode-vision plugin
(AGPL-3.0) — this is what intercepts the pasted image inside OpenCode and calls the
local_visiontool. This MCP server is the tool it calls. You need both.
Install
git clone https://github.com/WormAlien/opencode-openai-vision-mcp.git
cd opencode-openai-vision-mcp
npm install
Quick self-test (optional) — point it at your gateway and it should print a color word:
VISION_BASE_URL=http://localhost:20128/v1 \
VISION_API_KEY=your-key \
VISION_MODEL=your-vision-model \
node server.js
# then drive it with any MCP client, or just confirm it starts without error
Configure OpenCode
Add the MCP server to your opencode.json (see opencode.example.json):
{
"mcp": {
"local": {
"type": "local",
"command": ["node", "/absolute/path/to/opencode-openai-vision-mcp/server.js"],
"enabled": true,
"environment": {
"VISION_BASE_URL": "http://localhost:20128/v1",
"VISION_API_KEY": "YOUR_GATEWAY_API_KEY",
"VISION_MODEL": "your-vision-model-or-alias"
}
}
}
}
Naming the server
localmakes its tool resolve tolocal_vision, which matches the defaultimageAnalysisToolof the opencode-vision plugin — so no extra wiring needed.
Then enable the plugin for your models via opencode-vision.json
(see opencode-vision.example.json):
{
"models": ["your-provider/*"],
"imageAnalysisTool": "local_vision"
}
Restart OpenCode, select a model under that provider, paste an image, and ask away.
Environment variables
| Variable | Default | Description |
|---|---|---|
VISION_BASE_URL |
http://localhost:20128/v1 |
OpenAI-compatible base URL (must end in /v1). |
VISION_API_KEY |
(empty) | Bearer token for the endpoint. Omitted if empty. |
VISION_MODEL |
gpt-4o |
Vision model name, or a gateway alias. |
VISION_MAX_TOKENS |
1024 |
Max tokens for the description. |
Tip: point VISION_MODEL at a gateway alias (e.g. a vision alias in OmniRoute).
Then you can swap the real model in your gateway dashboard without editing any config.
The vision tool
- Input:
path(absolute path to a PNG/JPEG/WebP/GIF), optionalquestion. - Output: a text description (transcribes visible text by default).
- Handles both plain JSON and SSE/streamed responses from the endpoint.
Notes / limitations
- The image must be readable on the same machine the server runs on (it reads from the local filesystem path the plugin saved).
- Quality depends entirely on the vision model you point it at.
- Once OpenCode merges native image support for openai-compatible providers (#20802), you may not need this.
Credits
- opencode-vision (AGPL-3.0) — the OpenCode plugin that intercepts images and calls the MCP tool. A separate project; not bundled here.
- Model Context Protocol and its TypeScript SDK.
License
MIT — see LICENSE. (This applies to this MCP server only; the opencode-vision plugin has its own AGPL-3.0 license.)
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。