{"id":35419597,"url":"https://github.com/samestrin/chromium-screenshots","last_synced_at":"2026-01-13T19:50:06.591Z","repository":{"id":330375943,"uuid":"1120153256","full_name":"samestrin/chromium-screenshots","owner":"samestrin","description":"Vision AI \"Cortex\" for Agents. A Playwright-based MCP Server \u0026 API that captures screenshots with ground-truth DOM extraction and full auth state injection. Containerized.","archived":false,"fork":false,"pushed_at":"2026-01-02T14:09:08.000Z","size":309,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-05T17:16:27.130Z","etag":null,"topics":["ai-agents","automation","computer-use","docker-image","dom-extraction","headless-chrome","llm-tools","mcp-server","ocr","playwright-python","python-fastapi","scraping","screenshot-api","vision-ai","zero-drift"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samestrin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T15:46:46.000Z","updated_at":"2026-01-02T14:08:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/samestrin/chromium-screenshots","commit_stats":null,"previous_names":["samestrin/chromium-screenshots"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/samestrin/chromium-screenshots","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samestrin%2Fchromium-screenshots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samestrin%2Fchromium-screenshots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samestrin%2Fchromium-screenshots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samestrin%2Fchromium-screenshots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samestrin","download_url":"https://codeload.github.com/samestrin/chromium-screenshots/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samestrin%2Fchromium-screenshots/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28397906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","automation","computer-use","docker-image","dom-extraction","headless-chrome","llm-tools","mcp-server","ocr","playwright-python","python-fastapi","scraping","screenshot-api","vision-ai","zero-drift"],"created_at":"2026-01-02T16:14:19.368Z","updated_at":"2026-01-13T19:50:06.586Z","avatar_url":"https://github.com/samestrin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chromium-screenshots\n\n\u003e **The missing screenshot service for Vision AI \u0026 Auth.**\n\u003e *Inject auth. Extract DOM. Zero-drift capture. Pixel-perfect Chromium.*\n\n[![CI](https://github.com/samestrin/chromium-screenshots/actions/workflows/ci.yml/badge.svg)](https://github.com/samestrin/chromium-screenshots/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)\n[![Docker](https://img.shields.io/badge/docker-ready-blue?logo=docker)](https://hub.docker.com/)\n\n## ⚡ Why this exists\n\nTaking screenshots for **Vision AI** is hard. If you take a screenshot and then scrape the HTML separately, the page state drifts. Elements move. Popups appear. Your bounding boxes don't match the pixels.\n\n**chromium-screenshots** guarantees **Zero-Drift**. It extracts the DOM coordinates (ground truth) and the screenshot (pixels) from the exact same render frame.\n\n### Visual Proof\n\n![Chromium Screenshots Demo](https://vhs.charm.sh/vhs-6Vl8NFcVtMqKOQBhyNeWgZ.gif)\n\n| Feature | Standard Tools | chromium-screenshots |\n| :--- | :--- | :--- |\n| **Data Extraction** | ❌ Image Only | ✅ Image + DOM + Bounding Boxes |\n| **Quality Control** | ❌ None (hope it loaded) | ✅ **Quality Score** (Good/Low/Poor) |\n| **Auth Injection** | ❌ Cookies only | ✅ Cookies + LocalStorage + SessionStorage |\n| **AI Integration** | ❌ Manual API calls | ✅ Native MCP Server (Claude/Gemini) |\n| **SPA Support** | ❌ Fails on hydration | ✅ Waits for selectors/network idle |\n\n## 🤖 Standardized AI Integration\n\nThis tool is a \"visual cortex\" for your AI agents. It implements the **Model Context Protocol (MCP)**, allowing tools like Claude Desktop to natively control the browser.\n\n*   **`screenshot`**: Returns base64 data for immediate analysis (\"What does this button say?\").\n*   **`screenshot_to_file`**: Saves to disk to preserve context window tokens.\n*   **`extract_dom`**: Returns text + coordinates for ground-truth verification.\n\n## Comparison with Alternatives\n\nWhile many tools exist for browser automation and content extraction, `chromium-screenshots` is specifically designed to provide high-fidelity **observation** for AI agents, rather than just raw data or static images.\n\n| Tool Category | Examples | Screenshot | Structural Data | Quality Metric | Primary Focus |\n| :--- | :--- | :---: | :---: | :---: | :--- |\n| **Agent Observation** | **This Repo** | ✅ | ✅ (Atomic DOM) | ✅ | **AI Reliability \u0026 Context** |\n| **LLM RAG Scrapers** | Firecrawl, Jina | ✅ | ❌ (Markdown) | ❌ | Text extraction for reading |\n| **Screenshot APIs** | ScreenshotOne, ApiFlash | ✅ | ❌ (HTML) | ⚠️ (Basic) | Marketing \u0026 Archiving |\n| **Performance Audit** | Lighthouse CI | ✅ | ✅ (Full DOM) | ✅ | Speed \u0026 SEO Audits (Slow) |\n| **Visual Testing** | Percy, Chromatic | ✅ | ✅ (Snapshot) | ✅ | Regression Testing (Diffs) |\n\n## 🚀 Quick Start\n\n### Docker (Recommended)\n\nRun the containerized service. No dependencies required.\n\n```bash\ndocker compose up -d\n```\n\n\u003e The API is now active at `http://localhost:8000`.\n\n### Python (Local)\n\n```bash\npip install -r requirements.txt\nplaywright install chromium\nuvicorn app.main:app --reload\n```\n\n## 💡 Common Recipes\n\n### 1. Vision AI Ground Truth\nCapture screenshot + DOM data + Quality Score in one call.\n\n```bash\ncurl -X POST \"http://localhost:8000/screenshot\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"url\": \"https://news.ycombinator.com\",\n    \"extract_dom\": {\n      \"enabled\": true,\n      \"selectors\": [\"span.titleline \u003e a\"],\n      \"max_elements\": 50\n    }\n  }' -o hn_capture.png\n```\n\n### 2. The \"Impossible\" Auth Shot\nInject `localStorage` to capture authenticated dashboards (Wasp/Firebase).\n\n```bash\ncurl -X POST \"http://localhost:8000/screenshot\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"url\": \"https://app.example.com/dashboard\",\n    \"localStorage\": {\n      \"wasp:sessionId\": \"secret_session_token\",\n      \"theme\": \"dark\"\n    },\n    \"wait_for_selector\": \".dashboard-grid\"\n  }' -o dashboard.png\n```\n\n### 3. Vision AI Optimization\nGet quality metrics and model compatibility hints for Vision AI integrations.\n\n```bash\ncurl -X POST \"http://localhost:8000/screenshot/json\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"url\": \"https://news.ycombinator.com\",\n    \"extract_dom\": {\n      \"enabled\": true,\n      \"include_metrics\": true,\n      \"include_vision_hints\": true,\n      \"target_vision_model\": \"claude\"\n    }\n  }' | jq '{quality: .dom_extraction.quality, hints: .vision_hints}'\n```\n\n## 📚 Documentation\n\nDetailed references for core features:\n\n*   **[API Reference](docs/api-reference.md)** - Full endpoint and parameter guide.\n*   **[DOM Extraction](docs/dom-extraction.md)** - How to use ground-truth element coordinates.\n*   **[Quality Assessment](docs/quality-assessment.md)** - Understanding extraction quality and warnings.\n*   **[MCP Server](docs/mcp-server.md)** - Integration with Claude Desktop \u0026 AI agents.\n\n## 🧠 How It Works\n\n**The Zero-Drift Flow:**\n1. **Inject Auth:** Set `cookies` \u0026 `localStorage`.\n2. **Navigate:** Load page and wait for `networkidle`.\n3. **Freeze:** Pause execution.\n4. **Extract:** Scrape DOM positions \u0026 Text (JS evaluation).\n5. **Audit:** Run Quality Detection engine (count elements, check visibility).\n6. **Capture:** Take screenshot.\n7. **Return:** Send Image + JSON together.\n\n```mermaid\nsequenceDiagram\n    participant U as 👤 User / Agent\n    participant A as ⚡ API / MCP\n    participant B as 🕸️ Chromium\n    participant Q as 🔍 Quality Engine\n\n    U-\u003e\u003eA: POST /screenshot (extract_dom=true)\n    A-\u003e\u003eB: Create Context \u0026 Inject Auth\n    B-\u003e\u003eB: Navigate \u0026 Wait\n    \n    rect rgb(30, 30, 30)\n        note right of B: Critical Section\n        B-\u003e\u003eB: Extract DOM (JS)\n        B-\u003e\u003eQ: Assess Quality\n        Q--\u003e\u003eB: Quality: GOOD\n        B-\u003e\u003eB: Capture Pixels\n    end\n    \n    B--\u003e\u003eA: Result (Image + Metadata)\n    A--\u003e\u003eU: Return\n```\n\n## License\n\n[MIT License](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamestrin%2Fchromium-screenshots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamestrin%2Fchromium-screenshots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamestrin%2Fchromium-screenshots/lists"}