page-vision-mcp
Provides structured visual analysis tools for coding agents, enabling UI analysis, screenshot comparison, OCR, and crop-based refinement through VLM.
README
Page Vision MCP
Structured visual analysis pipeline for coding agents — give your AI agent the ability to see.
What It Does
Page Vision MCP turns visual analysis from a prompt into a tool. Instead of asking an LLM to "look at this image," your coding agent calls a structured API that returns consistent, machine-readable results with coordinates.
The Problem: AI coding agents modify frontend code but can't verify the result. They guess effects from source code alone.
The Solution: Screenshot → VLM Analysis → Structured JSON with coordinates → Agent makes informed decisions.
5 Tools:
| Tool | What It Does | VLM | Playwright |
|---|---|---|---|
capture_page |
Screenshot a webpage (fallback) | - | Yes |
analyze_ui |
Structured UI analysis with region-level localization | Yes | - |
compare_ui |
Screenshot diff with mode constraints | Yes | - |
extract_text |
Block-level OCR with coordinates | Yes | - |
crop_analyze |
Progressive crop refinement with depth guards | Yes | - |
3 Resources: vision://health | vision://version | vision://models
Pipeline
Screenshot ──> analyze_ui ──> Structured JSON
│
├── Need detail? ──> crop_analyze (depth +1)
├── Need text? ──> extract_text
└── Need diff? ──> compare_ui
Typical workflow:
"Check this page" ──> capture_page ──> analyze_ui ──> Agent finds issue
│
Agent fixes code
│
capture_page ──> compare_ui ──> Verified ✓
Quick Start
Install
pip install page-vision-mcp
# Optional: Playwright for screenshot fallback
pip install "page-vision-mcp[playwright]"
playwright install chromium
Configure
Set environment variables in your MCP client config (recommended) or create a .env file (see .env.example):
VISION_API_KEY=your-api-key
VISION_BASE_URL=https://api.openai.com/v1
VISION_MODEL_ID=gpt-4o
Works with any OpenAI-compatible VLM: GPT-4o, GLM-4V, Qwen-VL, etc.
MCP Client Config
Add to your MCP client configuration (Claude Code, Trae, Cursor, etc.):
{
"mcpServers": {
"page-vision-mcp": {
"command": "page-vision-mcp",
"env": {
"VISION_API_KEY": "your-api-key",
"VISION_BASE_URL": "https://api.openai.com/v1",
"VISION_MODEL_ID": "gpt-4o"
}
}
}
}
See examples/mcp_config.json for the full configuration with all options.
Tool Details
analyze_ui — UI Analysis
analyze_ui(
image_source="screenshot.png", # URL/path/base64/data_url
prompt="", # optional focus
task="ui", # ui/screenshot/qa/general
detail="high" # low/auto/high
)
Returns structured observations with region-level localization (page → section → component → text), inferences, uncertainties, and suggested regions for further analysis.
Example output:
{
"status": "success",
"result": {
"summary": "A dashboard with navigation bar, sidebar, and content area",
"observations": [
{"type": "component", "text": "Top navigation bar with 3 menu items", "bbox": [0.0, 0.0, 1.0, 0.08]},
{"type": "issue", "text": "Menu items too close together", "bbox": [0.15, 0.02, 0.6, 0.07]}
],
"suggested_regions": [
{"description": "Menu overlap area", "bbox": [0.15, 0.02, 0.6, 0.07], "reason": "Text may overlap, zoom in"}
]
}
}
compare_ui — Screenshot Diff
compare_ui(
image_before="before.png",
image_after="after.png",
mode="viewport", # viewport/fullpage/component
focus="changes" # changes/layout/text/colors/general
)
Returns structured differences (added/removed/modified/moved) with coordinates. Perfect for verifying code changes.
extract_text — OCR
extract_text(
image_source="screenshot.png",
language="auto", # auto/chinese/english/japanese/korean
preserve_layout=True
)
Returns text blocks with type, confidence, and bounding box coordinates. Preserves original language.
crop_analyze — Progressive Refinement
crop_analyze(
image_source="screenshot.png",
x=0.15, y=0.02, width=0.6, height=0.07, # normalized 0.0-1.0
depth=1, # agent-managed, max 3
task="ui"
)
Use coordinates from analyze_ui's suggested_regions. Max depth 3 prevents infinite recursion.
capture_page — Screenshot Fallback
capture_page(
url="http://localhost:3000",
viewport_width=1280,
viewport_height=720,
full_page=False,
wait_for="networkidle" # networkidle/domcontentload/load/none
)
Note: If your agent has built-in browser capability (Computer Use, Trae browser, Playwright MCP), use that instead and pass the screenshot path to analyze_ui.
Response Format
All tools return a structured JSON envelope:
{
"status": "success",
"tool": "analyze_ui",
"result": { ... },
"warnings": []
}
Status can be: success | partial | error | unavailable | unsupported | completed
Configuration
| Variable | Default | Description |
|---|---|---|
VISION_API_KEY |
- | VLM API key (required) |
VISION_BASE_URL |
https://api.openai.com/v1 |
VLM API endpoint |
VISION_MODEL_ID |
gpt-4o |
Model to use |
VISION_TIMEOUT |
60 |
Request timeout (seconds) |
VISION_MAX_RETRIES |
3 |
Max retry attempts |
VISION_ALLOW_LOCAL_FILES |
true |
Allow local file paths |
VISION_ALLOWED_PATHS |
- | Allowed directories (comma-separated) |
VISION_BLOCK_PRIVATE_IPS |
true |
Block SSRF to private IPs |
VISION_MAX_IMAGE_SIZE_MB |
10 |
Max image size |
VISION_MAX_IMAGE_PIXELS |
40000000 |
Max pixel count |
Security
- SSRF Protection: Private IP addresses are blocked by default (
VISION_BLOCK_PRIVATE_IPS) - Path Restriction: Local file access can be restricted to allowed directories (
VISION_ALLOWED_PATHS) - Image Limits: Max image size and pixel count prevent resource exhaustion
Development
pip install -e ".[dev]"
pytest tests/
License
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.