Skip to main content

Structured visual analysis pipeline for coding agents - give your AI agent the ability to see

Project description

Page Vision MCP

Structured visual analysis pipeline for coding agents — give your AI agent the ability to see.

PyPI Python License: MIT

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.

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

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 (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.

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.

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.

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

Development

pip install -e ".[dev]"
pytest tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

page_vision_mcp-0.1.0.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

page_vision_mcp-0.1.0-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file page_vision_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: page_vision_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for page_vision_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 93f99d496e467721b5073acd4615c4c3fb99341a7ac4feb4ebea2eb8be205a33
MD5 0b56c845310015ed935c6c053d1df72b
BLAKE2b-256 4e79d2e1ad5d0c8ead87537694ec9ad03e286cc1da5854b14c9648f022f020b1

See more details on using hashes here.

File details

Details for the file page_vision_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for page_vision_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfb84814fdf80e96339b03bafefea97b25cd7fa28884ca7542fa981e6a43d301
MD5 324a3c75927b182cfe4676be415d2771
BLAKE2b-256 3cf51e5036cc5153c4db99e62f5d4760a96eb9815bc4fc4474e492cadd14ce24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page