low-hallucination-vision
A low-hallucination vision MCP server that uses OpenAI-compatible multimodal models with structured prompts, confidence gating, and forced JSON to reduce false claims in image analysis.
README
Low-Hallucination Vision Toolkit
A drop-in replacement for high-hallucination vision MCPs (like the default
analyze_image), built on top of your own OpenAI-compatible multimodal model
(mimo v2.5). Two pieces that work together:
vision-mcp/ ← MCP server (Python). The engine. Plug into any agent.
vision-skill/ ← Skill (SKILL.md). The cross-verification workflow. Plug into ZCode.
Why this is lower-hallucination than a generic VLM call
It's not magic — it's five boring disciplines, all in the MCP layer:
- Mode-routed prompts — UI / general / OCR / detect each get a tightly scoped system prompt instead of one "describe everything" prompt.
- Forced structured JSON — every claim is an object with
confidence. - Low temperature (0.2 default) — less creative completion.
- "Allowed to be ignorant" — prompts explicitly forbid common-sense completion of details not actually visible.
- Confidence gating — the MCP reflags any claim below threshold as
"_flag": "存疑", so the agent can't accidentally report it as fact.
The Skill adds a sixth layer on top: cross-verification (run two independent modes and only trust claims both agree on).
Setup (uv-managed environment)
This project uses uv for environment management.
uv creates an isolated .venv per project and pins the Python version, so
nothing pollutes your global Python. The .venv is what VSCode auto-detects.
1. Install dependencies & create the venv
cd C:\Users\zrzring\ZCodeProject\vision-mcp
uv sync
That single command:
- reads
.python-version(3.12) and auto-downloads that Python if missing, - creates
vision-mcp\.venv, - installs everything in
pyproject.toml(currentlymcp[cli]).
To add a package later:
uv add <pkg>. To rebuild after pulling the repo: justuv syncagain. Never use rawpiphere — it would install into the wrong place.
Verify it works:
uv run python -c "import main; print('OK', main.mcp.name)"
# → OK low-hallucination-vision
2. Configure API credentials
copy .env.example .env # then edit .env
VISION_API_BASE=https://api.mimo.example.com/v1 # your OpenAI-compatible endpoint
VISION_API_KEY=sk-...
VISION_MODEL=mimo-vl-2.5
VISION_TEMPERATURE=0.2
3. Make VSCode detect the venv
VSCode's Python extension auto-detects .venv in the workspace. To be safe:
- Open the folder
C:\Users\zrzring\ZCodeProject(not the single file) in VSCode. - Install the Python extension (ms-python.python) if not already.
Ctrl+Shift+P→ Python: Select Interpreter → pick the one shown asPython 3.12.13 ('.venv')undervision-mcp\.venv\Scripts\python.exe.
If it doesn't show up, force it with a workspace setting — create
.vscode/settings.json in the project root:
{
"python.defaultInterpreterForWorkspace": "vision-mcp\\.venv\\Scripts\\python.exe",
"python.terminal.activateEnvironment": true
}
Now any terminal you open in VSCode auto-activates .venv, and you get
autocomplete / type-checking for mcp and your code.
4. Register the MCP server with your agents
The server speaks stdio MCP. Use uv run to launch it — this guarantees
the project's .venv is used regardless of the agent's working directory:
Claude Code — ~/.claude.json (or project .mcp.json):
{
"mcpServers": {
"low-hallucination-vision": {
"command": "uv",
"args": ["run", "--directory",
"C:\\Users\\zrzring\\ZCodeProject\\vision-mcp",
"python", "main.py"],
"env": {
"VISION_API_BASE": "https://api.mimo.example.com/v1",
"VISION_API_KEY": "sk-...",
"VISION_MODEL": "mimo-vl-2.5"
}
}
}
}
OpenCode — opencode.json:
{
"mcp": {
"low-hallucination-vision": {
"type": "local",
"command": ["uv", "run", "--directory",
"C:\\Users\\zrzring\\ZCodeProject\\vision-mcp",
"python", "main.py"],
"environment": {
"VISION_API_BASE": "https://api.mimo.example.com/v1",
"VISION_API_KEY": "sk-...",
"VISION_MODEL": "mimo-vl-2.5"
}
}
}
}
ZCode — same mcpServers shape as Claude Code.
Why
uv run --directoryinstead of a barepython? Because the agent may launch the server from any working directory;uv run --directoryalways activates the right.venv. Environment variables can live in the config (as above) OR invision-mcp/.env— either works.
Alternative: build a standalone vision-mcp.exe
If you'd rather not depend on uv/Python at runtime, package the server into
a single executable with PyInstaller. The exe is self-contained (~24 MB),
needs no Python installed, and works on any machine when shipped with its
.env. It runs in two modes: a stdio MCP server (default) and a
command-line image tool.
Build it
pyinstaller is already in pyproject.toml, so after uv sync:
cd C:\Users\zrzring\ZCodeProject\vision-mcp
uv run pyinstaller --onefile --name vision-mcp --collect-all mcp --clean --noconfirm main.py
Output lands in dist\vision-mcp.exe. The vision-mcp.spec file is
auto-generated; you can re-run pyinstaller vision-mcp.spec --noconfirm
after that for identical builds.
Put it on PATH and configure
-
Copy the exe and your
.envto a directory already on PATH (e.g.C:\Users\<you>\.local\bin):copy dist\vision-mcp.exe C:\Users\<you>\.local\bin\ copy .env C:\Users\<you>\.local\bin\ -
The exe reads
.envfrom its own directory first, then the source dir, then the working dir. So keep.envnext to the exe — change key/endpoint there, no rebuild needed. -
Verify from anywhere:
vision-mcp --help vision-mcp analyze C:\path\to\pic.png --mode general --prompt "describe it"
Register the exe with agents
Because the exe defaults to MCP-server mode, agent config is minimal — no
uv run, no args, no env block (creds come from the exe's .env):
Claude Code — ~/.claude.json (or project .mcp.json):
{
"mcpServers": {
"low-hallucination-vision": {
"command": "vision-mcp"
}
}
}
OpenCode — opencode.json:
{
"mcp": {
"low-hallucination-vision": {
"type": "local",
"command": ["vision-mcp"]
}
}
}
If vision-mcp isn't on PATH for the agent, use the full path instead:
"command": "C:\\Users\\<you>\\.local\\bin\\vision-mcp.exe".
CLI mode (use it directly, no agent)
The same exe doubles as a terminal image tool:
vision-mcp # = MCP server (default)
vision-mcp mcp # " (explicit)
vision-mcp analyze <image> [--mode general|ui_screenshot|ocr|detect] [--prompt "..."]
vision-mcp ocr <image> [--prompt "..."]
vision-mcp detect <image> [--prompt "..."]
<image> is a local path or an http(s) URL. Output is the same JSON the MCP
tools return (with bbox normalization + confidence flagging applied).
Source vs exe — which to use? Source (
uv run) is best while developing (editmain.py, reload instantly). The exe is best for daily use and sharing to other machines — no Python toolchain needed.
3. (Optional) Register the Skill with ZCode
Copy or symlink vision-skill/ into your skills directory so the
cross-verification workflow is auto-loaded:
<skills-dir>/low-hallucination-vision/SKILL.md
The Skill is agent-agnostic in content but only ZCode auto-discovers Skills. For Claude Code / OpenCode, the MCP tools alone still work — just keep the Skill's workflow in mind (or paste the relevant section into your own prompt).
Tools provided
| Tool | What it does | When to use |
|---|---|---|
analyze_image(image_source, mode, prompt, temperature) |
Structured analysis; mode = general / ui_screenshot / ocr / detect |
Default entry point |
ocr_extract(image_source, prompt, temperature) |
Text-only extraction | When you only need words |
detect_elements(image_source, prompt, temperature) |
Object detection with mandatory bbox | When you need locations |
All three return JSON. Claims below VISION_CONFIDENCE_THRESHOLD (default 0.6)
are tagged "_flag": "存疑".
image_source accepts either a local file path or an http(s) URL.
File map
ZCodeProject/
├── vision-mcp/ ← uv project (this README lives here)
│ ├── main.py ← the MCP server + CLI (engine + anti-hallucination)
│ ├── pyproject.toml ← deps: mcp[cli], pyinstaller
│ ├── uv.lock ← pinned versions (auto-generated)
│ ├── .python-version ← 3.12 (uv auto-downloads it)
│ ├── .env.example ← copy to .env and fill in
│ ├── vision-mcp.spec ← auto-generated by PyInstaller (for rebuilds)
│ ├── .venv/ ← created by `uv sync` (gitignored)
│ ├── build/ ← PyInstaller intermediates (gitignored)
│ └── dist/
│ └── vision-mcp.exe ← the standalone exe (built, gitignored)
└── .agents/ ← skill(s) discovered by ZCode
└── skills/vision-skill/
└── SKILL.md ← cross-verification workflow for the agent
Tuning
- Still too much hallucination? Lower
VISION_TEMPERATUREto 0.1 and raiseVISION_CONFIDENCE_THRESHOLDto 0.7. - Missing real things (over-conservative)? Lower the threshold to 0.5 and raise temperature slightly to 0.3.
- Model keeps breaking JSON? Some VLMs ignore schema instructions; in
that case the tool returns
"_parse_error": truewith the raw text so you can post-process. Consider switching to a model with stronger JSON support.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。