ollama-vision-mcp
ollama-vision-mcp
英文 · 中文
一个极简桥接服务,为只能使用纯文本模型(例如 DeepSeek)的 VS Code Copilot 提供本地视觉能力。
当 Copilot 使用纯文本模型时,它无法直接“看到”图像。这个 MCP 服务器弥补了这一缺口:你将截图放入文件夹;Copilot 通过该桥接读取图像 → 将其发送到本地 Ollama 视觉模型 → 得到文本描述,纯文本模型即可理解。
VS Code Copilot Chat (Agent mode, text-only model)
│ MCP stdio
▼
ollama-vision-mcp (this package)
│ Read local image → base64 → POST /v1/chat/completions
▼
Ollama (local vision model, e.g., qwen2.5vl:7b)工具
工具 | 参数 | 描述 |
|
| 读取图像并生成文本描述。 |
|
| 列出可供读取的图像文件。 |
|
| 通过 OCR 从图像中提取文本。 |
| — | 显示当前配置、Ollama 连接状态以及可用模型列表。 |
Related MCP server: Hybrid Vision MCP Server
本工具范围
本包仅是一个桥接层。它完全通过 HTTP 与 Ollama 通信(OpenAI 兼容的 /v1/chat/completions 和 /v1/models)。
它不处理:
安装 Ollama、启动
ollama serve、拉取模型或管理模型配置;访问剪贴板、IDE 内部机制,或除本地 Ollama 之外的任何网络服务。
你需自行负责安装 Ollama 和拉取模型(参见“先决条件”)。
先决条件
你必须自行完成以下设置:
Python 3.10+
Ollama 已安装并运行:
ollama serve至少已拉取一个视觉模型;推荐:
bash
ollama pull qwen2.5vl:7b其他选项:
qwen3-vl:8b、gemma3:12b、llama3.2-vision:11b、llava:7b。 选择适合你 GPU 的模型;稍后通过VISION_MCP_MODEL环境变量指定。
🚀 快速安装(推荐)
在仓库根目录运行一条命令即可完成安装和配置:
bash
cd ollama-vision-mcp
python setup_mcp.py该脚本将自动:
创建专用虚拟环境(
.venv)并安装本包(不污染全局环境)。检测本地 Ollama 服务并列出可用的视觉模型。
交互式引导你设置
base_url、model、inbox、max_tokens、图像压缩以及可选的 API Key。将配置写入项目的
.vscode/mcp.json和/或用户级全局 MCP 文件(%APPDATA%\Code\User\mcp.json),合并现有设置,不覆盖你的其他 MCP 服务器。
非交互式用法(适用于 CI/脚本):
bash
python setup_mcp.py --yes --project --model qwen2.5vl:7b
python setup_mcp.py --print # Only prints the config JSON, does not write to file安装后,在 VS Code 中重新加载窗口(Ctrl+Shift+P → “Developer: Reload Window”)以使配置生效。
如果你以前运行过,也可以直接使用命令
ollama-vision-setup重新配置。
验证安装
在 VS Code Copilot Chat(Agent 模式)中输入:
text
Run vision_status如果返回的 JSON 包含 "ollama": { "ok": true, ... } 和模型列表,则连接成功。
如果 ok 为 false,请先启动 Ollama(ollama serve)再重试。
使用方法
将截图放入项目的 inbox 目录(默认为
.ai/inbox)。服务器会在需要时自动创建该目录。在 Copilot Chat 中提问,例如:
“查看 inbox 中的截图,告诉我这个错误是关于什么的。”
Agent 将自动调用
list_images→describe_image,并根据文本描述进行回答。
让 Agent 更智能(可选):将现成的指令文件 .github/instructions/ollama-vision/vision-tools.instructions.md 复制到项目中的相同路径。它教会 Agent 完整的视觉工作流——调用顺序(list_images → describe_image → extract_text)、模式选择、故障排查,以及引导你将截图放入 inbox。作为 VS Code 的文件指令,只要任务涉及图像,它就会按需被发现,因此开箱即用,无需设置。
环境变量参考
变量 | 默认值 | 描述 |
|
| Ollama 的 OpenAI 兼容基础 URL |
|
| 要使用的视觉模型 |
| 空(实际使用 | API Key(被 Ollama 忽略) |
|
|
|
|
| 视觉模型的最大输出 token 数 |
|
| 如果图像超过 50KB,自动调整为 768px JPEG |
|
| 为思考模型保持思考启用( |
兼容别名:VISION_MODEL、VISION_BASE_URL、VISION_INBOX、VISION_API_KEY。
手动安装(备选)
如果你需要完全手动控制每一步,请参考以下流程。
1. 创建环境并安装
bash
cd ollama-vision-mcp
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS / Linux
pip install -e .安装后,你会得到两个命令:
ollama-vision-mcp— 启动 MCP 服务器ollama-vision-setup— 交互式配置快捷方式
2. 注册到 VS Code
将以下内容复制到项目的 .vscode/mcp.json(仅项目)或用户级文件 %APPDATA%\Code\User\mcp.json(所有项目)中。确保将 command 改为你的虚拟环境 Python 解释器的绝对路径:
json
{
"servers": {
"ollama-vision": {
"type": "stdio",
"command": "D:/MyRepos/ollama-vision-mcp/.venv/Scripts/python.exe",
"args": ["-m", "ollama_vision_mcp"],
"env": {
"VISION_MCP_BASE_URL": "http://localhost:11434/v1",
"VISION_MCP_MODEL": "qwen2.5vl:7b",
"VISION_MCP_INBOX": ".ai/inbox"
}
}
}
}⚠️
command必须是虚拟环境内 Python 解释器的绝对路径。 你也可以运行ollama-vision-setup --project自动生成此文件。 服务器在调用时使用os.getcwd(),因此相对路径(如path和 inbox 目录)将相对于服务器启动时的项目根目录来解析。
冒烟测试
运行以下脚本以检查 Ollama 连接、列出 inbox 内容,并对第一张图像执行真实的视觉调用:
bash
python examples/smoke_test.py许可证
MIT
Available Tools
4 toolsdescribe_imageA
Read a local image and return a text description from the local Ollama vision model.
Use when the user references a screenshot or image you cannot see.
path is absolute, or relative to the project directory.
Inputs: path (required), mode, question. Returns: result
extract_textA
Extract all visible text (OCR) from a local image verbatim.
Use for code screenshots, terminal output, or error dialogs.
Inputs: path (required). Returns: result
list_imagesA
List image files in a directory.
Defaults to the configured inbox folder where the user drops screenshots. Use this before describe_image to find what is available.
Inputs: directory. Returns: result
vision_statusA
Show bridge configuration and Ollama connectivity / available models.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
TDQS
Scored across 4 tools
Each tool has a clear, distinct purpose: list_images finds images, describe_image provides semantic description, extract_text performs OCR, and vision_status checks configuration. There is no overlap or ambiguity between them.
Tool names predominantly follow a verb_noun snake_case pattern (describe_image, list_images, extract_text). The exception is vision_status, which is noun_noun rather than verb_noun, but the inconsistency is minor and the naming style remains uniform.
With 4 tools, the server is well-scoped for a focused vision MCP. Each tool serves a necessary role in the image-analysis workflow, and the count is neither too sparse nor excessive.
The tool surface covers the core workflows: discovering available images, getting a semantic description, extracting text, and verifying connectivity. There are no obvious gaps that would prevent an agent from completing typical vision-related tasks.
Maintenance
Related MCP Connectors
OCR, transcription, file extraction, and image generation for AI agents via MCP.
MCP server exposing the YourImageShare upload API (upload/list/delete) as tools for AI agents.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
Related MCP Servers
- FlicenseAqualityDmaintenanceMCP server enabling LLM clients without vision capability to process images by delegating to local Ollama vision models. Supports describing images, OCR, asking questions, and processing clipboard images.4-
- AlicenseNot gradedqualityBmaintenanceBridges local vision engines (Tesseract.js OCR and Sharp preprocessing) with Ollama vision models for image analysis, comparison, text localization, and browser screenshot annotation over MCP-compliant HTTP/SSE transports.ISC
- AlicenseNot gradedqualityBmaintenanceMCP server for local Ollama vision analysis, enabling text-only agents like Claude Code to inspect images via a single tool. Processes images locally with Ollama, keeping image bytes on the machine and returning text reports.2MIT
- AlicenseAqualityCmaintenanceProvides vision understanding capabilities such as image analysis, OCR, object localization, and video frame analysis, plus optional image generation and editing, to coding agents via OpenAI-compatible multimodal models. Runs as a local MCP server with HTTP and stdio transports, configurable for clients like Codex, Claude Code, Kimi, and Cursor.321 npmMIT