Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

docs: document site scrape across guide, mcp, and skills

Luigi Agostia1d13bdf0f58
diff --git a/docs/index.json b/docs/index.json
index ca00d8b3..1f6ca24f 100644
--- a/docs/index.json
+++ b/docs/index.json
@@ -7,6 +7,7 @@
"headless-vs-headed.md",
"dashboard.md",
"audit.md",
+ "scrape.md",
"mcp.md",
"benchmark.md"
],
diff --git a/docs/mcp.md b/docs/mcp.md
index 4e7d910e..3305ab08 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -81,12 +81,13 @@ pinchtab --server http://remote:9867 mcp
## Available Tools
-PinchTab currently exposes 38 tools:
+PinchTab currently exposes 39 tools:
- Navigation: 5
- Interaction: 9
- Keyboard: 4
- Content: 3
+- Site: 1
- Tab management: 5
- Wait utilities: 6
- Network: 5
@@ -125,6 +126,10 @@ PinchTab currently exposes 38 tools:
- `pinchtab_pdf`
- `pinchtab_find`
+### Site
+
+- `pinchtab_scrape` — crawl a site to markdown (HTTP-first, browser-enrich thin/JS pages). Use `preview=true` for a cheap outline, then expand chosen URLs with `only`.
+
### Tab Management
- `pinchtab_list_tabs`
diff --git a/docs/pinchtab-scrape-audit-spec.md b/docs/pinchtab-scrape-audit-spec.md
new file mode 100644
index 00000000..2c5d5409
--- /dev/null
+++ b/docs/pinchtab-scrape-audit-spec.md
@@ -0,0 +1,153 @@
+# PinchTab Scraping & Audit Spec
+
+## Overview
+
+PinchTab serves as the **deep browser enhancement layer** on top of SeaPortal's discovery and HTTP extraction. It adds visual, interactive, performance, and security capabilities that pure HTTP scraping cannot provide.
+
+## Core Command
+
+```bash
+pinchtab audit <url> [flags]
+pinchtab compare <live-url> <staging-url> [flags]
+```
+
+## Responsibilities
+
+1. **Consume SeaPortal output** as base data
+2. **Enrich sampled pages** with browser-specific data
+3. **Run visual regression** (when comparing versions)
+4. **Generate final rich report** (or send structured data to LLM)
+
+## Input
+
+- SeaPortal `SiteReport` JSON (or direct URL + sitemap data)
+- Optional: authentication details (cookies, login flow)
+- Comparison baseline (for diff mode)
+
+## Output
+
+Enhanced `SiteReport` with browser-enriched fields per page.
+
+## Page Enhancement Fields (PinchTab)
+
+```go
+type BrowserPageData struct {
+ ScreenshotPath string
+ FullPageScreenshot bool
+ ConsoleLogs []ConsoleLogEntry
+ NetworkRequests []NetworkRequest
+ BrokenAssets []BrokenAsset // especially 404 images
+ InteractiveElements []InteractiveElement
+ AccessibilityScore int
+ VisualDiff *VisualDiffResult // only in compare mode
+ TimingMetrics BrowserTimingMetrics
+}
+```
+
+## Key Features
+
+### 1. Visual Analysis
+- Full-page screenshots
+- Image diffing (for compare mode)
+- Highlighted diff images with annotations
+
+### 2. Console & JS Monitoring
+- Capture all console logs, errors, warnings
+- Filter critical JS errors
+
+### 3. Network Monitoring
+- Track all resource requests
+- Detect broken images, scripts, stylesheets (404, 500, etc.)
+- Monitor API failures
+
+### 4. Performance (Browser-level)
+- Core Web Vitals (via CDP)
+- Navigation timing
+- Resource loading breakdown
+
+### 5. Usability & Accessibility
+- Basic a11y checks
+- Missing form labels, alt texts
+- Navigation flow validation
+
+### 6. Security Surface (optional)
+- Integration point for Nuclei or similar
+- Exposed endpoints detection
+- Mixed content warnings
+
+## Sampling & Scalability
+
+- Respect SeaPortal's page groups and samples
+- Allow overriding sample size
+- Parallel processing with configurable concurrency
+- Smart prioritization (homepage, key flows first)
+
+### Preview → Expand (large sites)
+
+Full-fidelity scraping of a large site is expensive twice over: shipping every
+page's markdown body dominates the token cost, and browser-rendering every
+routed page dominates the wall-clock cost. To let a model survey first and
+drill down second, the scrape runs in two cheap-then-deep passes:
+
+1. **Preview** (`scrape <url> --preview`, `preview: true`): the HTTP crawl and
+ per-page routing verdict, but **no browser rendering** and **no full page
+ bodies**. Each page's markdown is withheld and replaced by:
+ - `charCount` — size of the extracted content, so the caller can gauge how
+ heavy a full expand would be
+ - `snippet` — a leading, whitespace-collapsed slice of the content
+ - the page's existing `meta`/description and `contentType`
+
+ The result is an outline the model reads cheaply to decide what matters.
+
+2. **Expand** (`scrape <url> --only <url> [--only <url> …]`, `only: [...]`):
+ scrapes **exactly the chosen URLs** at full fidelity (HTTP extract + browser
+ render per the normal routing) instead of re-discovering the site. It is
+ stateless — the model hands back the exact URLs it saw in the preview; no
+ server-side session or cache is kept.
+
+Both passes reuse the same navigation security stack: every preview crawl fetch
+and every expand fetch (`FetchBytes` with the `CrawlGuard` policy) goes through
+the same SSRF/redirect vetting as browser navigation.
+
+## Report Structure
+
+(See previous combined report templates with sections for:)
+- Summary Score
+- SEO & Metadata
+- Content & Functionality
+- Visual Differences
+- Performance
+- Console & JS Errors
+- Broken Assets / Images
+- Usability Issues
+- Security Findings
+- Recommendations
+
+## Integration Points
+
+- Library mode: `pinchtab.EnrichWithBrowser(seaPortalReport)`
+- CLI for standalone use
+- Docker-friendly for CI/CD
+- Output formats: JSON (for LLM), Markdown/HTML report, PDF
+
+## Authentication Support
+
+- Cookie injection
+- Login flow recording/replay
+- Headless + stealth options
+
+## Flags (examples)
+
+- `--sample-size int`
+- `--screenshot`
+- `--network-monitor`
+- `--visual-diff`
+- `--llm-refine`
+- `--output-dir`
+- `--concurrency int`
+
+---
+
+**Status**: Ready for implementation planning.
+
+This complements the SeaPortal spec perfectly.
diff --git a/docs/reference/mcp-tools.md b/docs/reference/mcp-tools.md
index 76ea5e78..864d58c0 100644
--- a/docs/reference/mcp-tools.md
+++ b/docs/reference/mcp-tools.md
@@ -1,6 +1,6 @@
# MCP Tool Reference
-PinchTab currently exposes 41 MCP tools. All tool names are prefixed with `pinchtab_` and are served over stdio JSON-RPC.
+PinchTab currently exposes 43 MCP tools. All tool names are prefixed with `pinchtab_` and are served over stdio JSON-RPC.
For selector-based interaction tools, prefer `selector`. `ref` and `query` are still accepted as deprecated/alias fallbacks on the element-action tools (`query` is shorthand for `find:<text>`).
@@ -63,6 +63,12 @@ All element-action tools accept the unified `selector` and the legacy aliases `r
| `pinchtab_pdf` | `tabId`, `landscape`, `scale`, `pageRanges` | Returns base64-encoded PDF content |
| `pinchtab_find` | `query` required, `tabId` | Semantic element search; returns `best_ref` and selector hints to reuse in action tools |
+## Site
+
+| Tool | Key Parameters | Notes |
+| --- | --- | --- |
+| `pinchtab_scrape` | `url` required, `preview`, `only`, `maxPages`, `maxPerPattern`, `include`, `exclude`, `concurrency`, `enrichAll`, `noBrowser`, `timeoutSeconds`, `browser` | Crawl a whole site to a page tree of markdown via `/scrape`. HTTP-first extraction; only thin/blocked/failed pages are browser-rendered. `preview=true` returns a cheap outline (sizes + snippets, no bodies, no browser); `only` (comma-separated URLs) expands chosen pages at full fidelity. `include`/`exclude` are comma-separated regexes. Full reports can be large — prefer preview then expand. Runs with an extended timeout (multi-page crawls take minutes) |
+
## Tab Management
| Tool | Key Parameters | Notes |
diff --git a/docs/scrape.md b/docs/scrape.md
new file mode 100644
index 00000000..76e8a2fa
--- /dev/null
+++ b/docs/scrape.md
@@ -0,0 +1,172 @@
+# Site Scrape
+
+`pinchtab scrape` turns a whole site into a page tree of markdown content.
+Pages are discovered and extracted over plain HTTP first (via SeaPortal: sitemap
+or link crawl, URL-pattern sampling). Only pages whose HTTP extraction comes back
+thin, blocked, or failed are re-rendered in the real browser and re-extracted
+from the rendered DOM — so JavaScript-only content still lands in the report,
+while static pages never pay for a browser.
+
+The pipeline:
+
+```
+seaportal (HTTP crawl & extraction) → routing → pinchtab (browser) → report
+ sitemap/link crawl, URL-pattern thin / render + re-extract json / md
+ sampling, per-page markdown blocked? JS-only pages page tree
+```
+
+SeaPortal does the cheap HTTP work; the browser — the expensive resource — runs
+only where HTTP was not enough. Every page records where its content came from
+(`http` or `browser`) and the routing verdict that put it there.
+
+## Quick start
+
+```bash
+pinchtab scrape https://example.com --output-dir ./scrape
+# → ./scrape/report.json
+```
+
+Also write a human-readable digest and print a summary:
+
+```bash
+pinchtab scrape https://example.com --format md --output-dir ./scrape
+# → ./scrape/report.json + ./scrape/report.md
+```
+
+## Preview → Expand (large sites)
+
+Scraping a large site at full fidelity is expensive twice over: shipping every
+page's markdown dominates the token cost, and browser-rendering every routed
+page dominates the wall-clock cost. To survey first and drill down second, run
+the scrape in two cheap-then-deep passes.
+
+**1. Preview** — the HTTP crawl and per-page routing verdict, but no browser
+rendering and no full page bodies. Each page's markdown is withheld and replaced
+by a `charCount` (how heavy a full expand would be) and a leading `snippet`:
+
+```bash
+pinchtab scrape https://example.com --preview
+# https://example.com/ · 4229 chars
+# Browser control for AI agents. 12MB Go binary…
+# https://example.com/docs/app · 87 chars · needs browser: thin-content
+# Loading…
+```
+
+**2. Expand** — scrape exactly the URLs you picked, at full fidelity (HTTP
+extract + browser render per the normal routing), instead of re-crawling:
+
+```bash
+pinchtab scrape https://example.com \
+ --only https://example.com/docs/app \
+ --only https://example.com/pricing \
+ --output-dir ./scrape
+```
+
+Expand is stateless: hand back the exact URLs the preview showed. No server-side
+session or cache is kept.
+
+## `pinchtab scrape`
+
+```
+pinchtab scrape <url> [flags]
+```
+
+The argument is the site URL. Discovery seeds from that host's root: SeaPortal
+looks for `robots.txt` and `sitemap.xml` at the host root and, failing that,
+link-crawls from the root page.
+
+| Flag | Default | Meaning |
+|---|---|---|
+| `--preview` | false | Outline only: page tree, `charCount`, and `snippet` per page — no browser rendering or full bodies |
+| `--only <url>` | | Expand exactly these URLs at full fidelity instead of crawling (repeatable) |
+| `--max-pages <n>` | 50 | Maximum pages sampled across the whole site |
+| `--max-per-pattern <n>` | 8 | Maximum pages sampled per URL-pattern group (e.g. `/blog/*`) |
+| `--include <regex>` | | Only crawl URLs matching this regex (repeatable) |
+| `--exclude <regex>` | | Skip URLs matching this regex (repeatable) |
+| `--enrich-all` | false | Browser-render every reachable page, ignoring routing |
+| `--no-browser` | false | HTTP crawl only; record routing verdicts without browser rendering |
+| `--concurrency <n>` | 2 | Pages browser-rendered in parallel (max 8) |
+| `--timeout <s>` | 60 | Overall HTTP crawl timeout in seconds |
+| `--output-dir <dir>` | | Write `report.json` (and `report.md` with `--format md`) to this directory |
+| `--format <f>` | json | Report format: `json` or `md` |
+| `--json` | false | Print the full report JSON to stdout |
+| `--cookie name=value` | | Inject a cookie before the run (repeatable; the cookie jar is cleared afterwards) |
+| `--cookies-file <file>` | | Inject cookies from a JSON array of `{name, value, domain, ...}` objects |
+| `--profile <name>` | | Run against the instance of this browser profile |
+
+Failure contract: a page that fails in **both** engines does not fail the run —
+the command exits 0 and that page's report entry carries an `error` field. A
+failed browser enrichment keeps the HTTP extraction and records `browserError`.
+The run itself only errors when the crawl fails outright or discovers no pages.
+
+### Routing
+
+Each HTTP-extracted page is scored for whether the browser should re-render it:
+
+- **not-found** (404 / 410) never routes — re-rendering cannot recover content.
+- **fetch-error** or a **blocked status** (401, 403, 407, 429, 503) routes: a
+ real browser with stealth and challenge handling may succeed where a plain
+ HTTP client was refused.
+- **thin-content** (extraction shorter than the static-ok threshold) routes: a
+ probable JavaScript shell.
+
+`--enrich-all` forces every non-404 page to the browser; `--no-browser` records
+the verdict on each page but renders nothing.
+
+## Report anatomy
+
+`report.json` is a versioned scrape report (`schemaVersion`):
+
+```
+schemaVersion, generatedAt, input
+site: baseUrl, title, sitemapFound, totalDiscovered, sampledPages
+pageGroups[]: pattern, total, sampled, urls[] # site tree by URL pattern
+pages[]:
+ url, title, statusCode, contentType
+ markdown # withheld in preview mode
+ charCount, snippet # set in preview mode instead of markdown
+ meta, schema, internalLinks, externalLinks
+ source # "http" or "browser"
+ browserRecommended, browserReasons # the routing verdict
+ browserError? # browser enrichment failed; HTTP content kept
+ error? # page failed in both engines
+summary: contentTypes, httpPages, browserPages, failedPages, recommendations
+```
+
+`--format md` writes `report.md` next to `report.json` (or prints to stdout
+without `--output-dir`): a single digest with the site overview, the page tree
+by URL pattern, and each page's content (or its snippet in preview mode).
+
+## HTTP API
+
+The CLI is a thin client over one endpoint:
+
+- `POST /scrape {"url", "preview", "only", "maxPages", "maxPerPattern",
+ "includePatterns", "excludePatterns", "concurrency", "enrichAll",
+ "noBrowser", "timeoutSeconds"}` → the scrape report
+
+Every crawl fetch and every expand fetch goes through the same SSRF/redirect
+navigation guard as browser navigation.
+
+## MCP
+
+Agents can drive the same flow over MCP with the `pinchtab_scrape` tool. Prefer
+`preview=true` for a cheap outline, then expand with `only` (comma-separated
+URLs) — the full report can be large. See [MCP Server](mcp.md).
+
+```
+pinchtab_scrape { "url": "https://example.com", "preview": true }
+pinchtab_scrape { "url": "https://example.com", "only": "https://example.com/a, https://example.com/b" }
+```
+
+## Docker / CI
+
+The scrape CLI is a thin client over a running pinchtab server, so in Docker run
+the server container first and exec the scrape against it (see
+[guides/docker.md](guides/docker.md) for the server setup):
+
+```bash
+docker run -d --name pinchtab -v pinchtab-data:/data --shm-size=2g pinchtab/pinchtab
+docker exec pinchtab pinchtab scrape https://example.com --output-dir /data/scrape
+docker cp pinchtab:/data/scrape ./scrape
+```
diff --git a/skills/pinchtab-mcp/SKILL.md b/skills/pinchtab-mcp/SKILL.md
index d6994cba..27ec24c8 100644
--- a/skills/pinchtab-mcp/SKILL.md
+++ b/skills/pinchtab-mcp/SKILL.md
@@ -34,6 +34,7 @@ Choose the cheapest tool that satisfies your goal:
| Check a specific value | `pinchtab_eval(expression="document.title")` | Lowest |
| Find a specific element | `pinchtab_find(query="login button")` | Low |
| Read page text only | `pinchtab_get_text()` | Low |
+| Read a whole site to markdown | `pinchtab_scrape(url=..., preview=true)` then expand | Varies |
| Find interactive elements | `pinchtab_snapshot(interactive=true, compact=true)` | Medium |
| Full page structure | `pinchtab_snapshot()` | Medium-High |
| Visual verification | `pinchtab_screenshot()` | Highest |
@@ -57,6 +58,20 @@ pinchtab_navigate(url="https://example.com")
---
+## Site scrape
+
+To read a **whole site** (not one page) into markdown, use `pinchtab_scrape` — it crawls over HTTP first and browser-renders only the pages that need it (thin, blocked, or JS-only).
+
+```
+pinchtab_scrape(url="https://example.com", preview=true)
+```
+
+- **Large sites**: call with `preview=true` first for a token-cheap outline (per-page titles, sizes, snippets, and which pages need the browser — no full bodies). Full reports can be large; don't scrape everything blind.
+- **Drill down**: expand the pages you picked from the preview with `only` (comma-separated URLs): `pinchtab_scrape(url="https://example.com", only="https://example.com/a, https://example.com/b")`.
+- `noBrowser=true` for an HTTP-only crawl; `enrichAll=true` to browser-render every page. Multi-page crawls run for minutes.
+
+---
+
## Observation
### Snapshot (primary)
diff --git a/skills/pinchtab/SKILL.md b/skills/pinchtab/SKILL.md
index 548bc5d9..b3b5aab6 100644
--- a/skills/pinchtab/SKILL.md
+++ b/skills/pinchtab/SKILL.md
@@ -263,6 +263,19 @@ pinchtab compare <live-url> <staging-url> --fail-on-diff
Reports capture console errors, broken assets, interactive elements, accessibility score + findings, Core Web Vitals, and rule-based security findings per page. Pages that fail to load stay in the report with an `error` field (the run still exits 0). Full reference: [docs/audit.md](https://pinchtab.com/docs/audit).
+### Site scrape
+
+```bash
+pinchtab scrape <url> --output-dir ./scrape # HTTP-first crawl → report.json; browser-renders only thin/blocked/JS pages
+pinchtab scrape <url> --format md --output-dir ./scrape # also write report.md digest (page tree + per-page content)
+pinchtab scrape <url> --json # print the full scrape report JSON (agent-friendly)
+pinchtab scrape <url> --preview # cheap outline of a large site: titles, sizes, snippets, routing verdicts — no browser, no bodies
+pinchtab scrape <url> --only <page-url> --only <page-url2> # expand exactly these pages at full fidelity (drill down after --preview)
+pinchtab scrape <url> --no-browser # HTTP crawl only; still records which pages need the browser
+```
+
+Turns a whole site into a page tree of markdown. Each page records its content `source` (`http` or `browser`) and the routing verdict; pages that fail in both engines stay in the report with an `error` field (the run still exits 0). For a large site, `--preview` first for a token-cheap survey, then `--only <urls>` to expand what matters. Full reference: [docs/scrape.md](https://pinchtab.com/docs/scrape).
+
### Advanced (explicit opt-in only)
These operations are high-impact and gated by security policy. Do not use unless the task specifically requires them and simpler commands are insufficient.