High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
package mcp
import (
"strconv"
"github.com/mark3labs/mcp-go/mcp"
"github.com/pinchtab/pinchtab/internal/scroll"
)
const positionalWrapperGrammar = " first/last/nth index matches in document order for every selector kind, so nth:0 is the first match in the page. A bare text: selector instead picks the most control-like smallest match, so text:X and first:text:X can differ."
// scrollStepDescription states the direction magnitude in the tool description, read
// from the owner rather than written out: an agent reads these descriptions fresh on
// every session, so this is where the distance becomes discoverable — without it,
// 'steps' is only usable by a caller who already knows an undocumented default.
var scrollStepDescription = strconv.Itoa(scroll.StepPixels) + "px"
// allTools returns every MCP tool exposed by the PinchTab MCP server.
func allTools() []mcp.Tool {
return []mcp.Tool{
mcp.NewTool("pinchtab_navigate",
mcp.WithDescription("Navigate to a URL in the browser"),
mcp.WithString("url", mcp.Required(), mcp.Description("The URL to navigate to")),
tabIDParam(),
mcp.WithBoolean("newTab", mcp.Description("Open the URL in a new tab instead of reusing the current one; the returned tabId targets it in later tools")),
mcp.WithBoolean("snap", mcp.Description("Return interactive compact snapshot after navigation (saves a round-trip)")),
browserParam(),
),
mcp.NewTool("pinchtab_back",
mcp.WithDescription("Go back one entry in the tab's session history. Returns the tab ID and the URL the tab landed on, so a redirect or bfcache restore is visible without a snapshot."),
tabIDParam(),
snapParam(),
browserParam(),
),
mcp.NewTool("pinchtab_forward",
mcp.WithDescription("Go forward one entry in the tab's session history. Returns the tab ID and the URL the tab landed on."),
tabIDParam(),
snapParam(),
browserParam(),
),
mcp.NewTool("pinchtab_reload",
mcp.WithDescription("Reload the current page. Returns the tab ID and the URL the tab landed on."),
tabIDParam(),
snapParam(),
browserParam(),
),
mcp.NewTool("pinchtab_snapshot",
mcp.WithDescription("Get an accessibility tree snapshot of the current page. Use this sparingly: prefer pinchtab_find + action selectors for faster loops."),
tabIDParam(),
mcp.WithBoolean("interactive", mcp.Description("Only interactive elements (buttons, links, inputs)")),
mcp.WithBoolean("compact", mcp.Description("Compact format (default; false=JSON)")),
mcp.WithString("format", mcp.Description("Output format: 'compact' or 'text'")),
mcp.WithBoolean("diff", mcp.Description("Only changes since last snapshot")),
mcp.WithString("selector", mcp.Description("Unified selector to scope the snapshot (ref, CSS, XPath, text, find, role, label, placeholder, alt, title, testid, first/last/nth). Selectors resolve in the current frame scope; use pinchtab_frame for iframe content."+positionalWrapperGrammar)),
mcp.WithNumber("maxTokens", mcp.Description("Maximum estimated tokens in response (e.g. 300)")),
mcp.WithNumber("depth", mcp.Description("Maximum tree depth (e.g. 3)")),
mcp.WithBoolean("noAnimations", mcp.Description("Disable animations before capturing the snapshot")),
browserParam(),
),
mcp.NewTool("pinchtab_frame",
mcp.WithDescription("Get or set the current frame scope for selector-based actions and snapshots"),
tabIDParam(),
mcp.WithString("target", mcp.Description("Frame target: 'main', a snapshot ref, a selector for an iframe element, or a frame name/URL")),
browserParam(),
),
mcp.NewTool("pinchtab_screenshot",
mcp.WithDescription("Take a screenshot of the current page. The result is delivered as an MCP image content block (image/jpeg by default, image/png with format='png') so clients render it directly. The accompanying text block is always a JSON envelope `{\"format\": \"jpeg\"|\"png\", \"annotations\": [...]}` — `annotations` is an empty array by default. With `annotate=true`, the picture has numbered overlay boxes on interactive elements and `annotations` is populated with `[{\"ref\": \"e5\", \"role\": \"button\", \"name\": \"Submit\", \"tag\": \"button\", \"box\": {\"x\": <number>, \"y\": <number>, \"w\": <number>, \"h\": <number>}}, ...]`; the `ref` values reuse the same selectors as pinchtab_click/fill/etc. Set `beyondViewport=true` to capture the entire scrollable document instead of the visible viewport."),
tabIDParam(),
mcp.WithString("selector", mcp.Description("Unified selector. Without annotate it clips the screenshot to the element. With annotate=true it narrows which elements receive overlay boxes (default: all interactive elements).")),
imageFormatParam(),
mcp.WithNumber("quality", mcp.Description("JPEG quality 0-100 (only for JPEG format)")),
mcp.WithNumber("scale", mcp.Description("Rescale the output image bitmap. Default 1 (native). 0.5 halves each axis (quarter of the pixels).")),
mcp.WithBoolean("annotate", mcp.Description("Overlay numbered ref boxes on interactive elements (or on selector matches). Returns the image plus a structured list of {ref, role, name, box}.")),
mcp.WithBoolean("beyondViewport", mcp.Description("Capture the entire scrollable document, not just the visible viewport. Box coordinates in the annotations envelope are document-relative when this is true. Ignored when selector is set.")),
browserParam(),
),
mcp.NewTool("pinchtab_capture",
mcp.WithDescription("Paired screenshot + accessibility snapshot from the same DOM epoch. Returns an image content block plus a JSON envelope `{url, title, epoch:{frameId,loaderId,domEpoch}, pairing:{navigated,captureDurationMs}, image:{format,bytes,coordinateSpace,devicePixelRatio,viewport,clip}, snapshot:{filter,nodeCount,nodes}}`. Each node in `snapshot.nodes` may carry a `boundingBox:{x,y,w,h}` and `visible:bool` so a vision-capable model can overlay refs on pixels. Coordinate space is 'viewport' by default, 'document' when beyondViewport=true, and 'clip' when selector is set. Prefer this over a separate snapshot+screenshot pair whenever the model needs both image and refs."),
tabIDParam(),
mcp.WithString("selector", mcp.Description("Scope: clips screenshot and filters snapshot subtree to the same element. Wins over beyondViewport.")),
mcp.WithString("filter", mcp.Description("Snapshot filter: 'interactive' (default) or 'all'")),
imageFormatParam(),
mcp.WithNumber("quality", mcp.Description("JPEG quality 0-100 (JPEG only)")),
mcp.WithNumber("depth", mcp.Description("Snapshot tree depth limit (e.g. 3)")),
mcp.WithNumber("scale", mcp.Description("Rescale the output image bitmap. Default 1 (native). 0.5 halves each axis.")),
mcp.WithString("wait", mcp.Description("Lifecycle wait before capture: 'stable' (default — waits for Page.lifecycleEvent quiescence), 'load' (polls document.readyState until complete), or 'none'")),
mcp.WithBoolean("withBounds", mcp.Description("Populate boundingBox + visible on snapshot nodes (default true). Set false to skip per-node DOM.getBoxModel round trips when bounds are not needed.")),
mcp.WithBoolean("beyondViewport", mcp.Description("Capture the full scrollable document instead of just the visible viewport. Coordinate space becomes 'document'; bounding boxes use page coords.")),
mcp.WithBoolean("requirePair", mcp.Description("Return 409 if the main frame navigates during the capture window (loaderId changes).")),
mcp.WithBoolean("noAnimations", mcp.Description("Inject prefers-reduced-motion CSS for the capture window")),
mcp.WithString("browser",
mcp.Description("Browser to use for this request (e.g. chrome, cloak). The static ghost-chrome runtime cannot paint, so it falls back to chrome.")),
),
mcp.NewTool("pinchtab_get_text",
mcp.WithDescription("Extract readable text content from the current page. Inherits the current frame scope for the tab unless no frame is selected."),
tabIDParam(),
mcp.WithString("mode", mcp.Description("Extraction mode: 'readability' (default), 'raw', or 'markdown' (preserves links and tables; best for articles). Supersedes raw.")),
mcp.WithBoolean("raw", mcp.Description("Return raw text without formatting")),
mcp.WithString("format", mcp.Description("Response format: 'text'/'plain' for plain text, default JSON envelope")),
mcp.WithNumber("maxChars", mcp.Description("Maximum characters in response (e.g. 3000)")),
browserParam(),
),
mcp.NewTool("pinchtab_click",
mcp.WithDescription("Click an element. Prefer selector from pinchtab_find.best_ref (e.g. 'e5') to avoid extra snapshots."),
mcp.WithString("selector", mcp.Description("Unified selector: ref (e.g. 'e5'), CSS, XPath, text, find, role, label, placeholder, alt, title, testid, or first/last/nth. Non-ref selectors resolve in the current frame scope."+positionalWrapperGrammar)),
selectorAliasParams(),
mcp.WithString("query", mcp.Description("Alias for semantic targeting when selector is omitted (example: 'login button' -> find:login button)")),
mcp.WithString("dialogAction", mcp.Description("Optional one-shot dialog handling for this click: 'accept' or 'dismiss'")),
mcp.WithString("dialogText", mcp.Description("Optional prompt text used with dialogAction='accept'")),
stringAliasParam("onDialog", "dialogAction"),
stringAliasParam("promptText", "dialogText"),
mcp.WithNumber("x", mcp.Description("Optional X coordinate for coordinate click")),
mcp.WithNumber("y", mcp.Description("Optional Y coordinate for coordinate click")),
nodeIDParam(),
mcp.WithBoolean("waitNav", mcp.Description("Wait for navigation after the click when the element triggers a page change")),
mcp.WithString("mode", mcp.Description("Optional click delivery override: 'dom' for element.click() or 'dispatch' for synthetic click events on the target")),
humanizeParam(),
mcp.WithBoolean("snap", mcp.Description("Return interactive compact snapshot after click (saves a round-trip)")),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_type",
mcp.WithDescription("Type text into an input element"),
selectorParam(),
selectorAliasParams(),
queryParam(),
textToTypeParam(),
stringAliasParam("value", "text"),
nodeIDParam(),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_hover",
mcp.WithDescription("Hover over an element"),
selectorParam(),
selectorAliasParams(),
queryParam(),
mcp.WithNumber("x", mcp.Description("Optional X coordinate for coordinate hover")),
mcp.WithNumber("y", mcp.Description("Optional Y coordinate for coordinate hover")),
nodeIDParam(),
humanizeParam(),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_focus",
mcp.WithDescription("Focus an element"),
selectorParam(),
selectorAliasParams(),
queryParam(),
nodeIDParam(),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_select",
mcp.WithDescription("Select a dropdown option by value or visible text"),
mcp.WithString("selector", mcp.Description("Unified selector for the select element. Non-ref selectors resolve in the current frame scope.")),
selectorAliasParams(),
queryParam(),
mcp.WithString("value", mcp.Required(), mcp.Description("Option value or visible text to select")),
stringAliasParam("option", "value"),
nodeIDParam(),
tabIDParam(),
mcp.WithBoolean("snap", mcp.Description("Return interactive compact snapshot after select (saves a round-trip)")),
browserParam(),
),
mcp.NewTool("pinchtab_scroll",
mcp.WithDescription("Scroll the page or an element. For element targeting + pixel deltas, this automatically uses wheel semantics for smoother behavior."),
mcp.WithString("selector", mcp.Description("Unified selector for element to scroll (omit for page scroll). Non-ref selectors resolve in the current frame scope.")),
selectorAliasParams(),
queryParam(),
mcp.WithNumber("pixels", mcp.Description("Number of pixels to scroll (positive=down, negative=up)")),
mcp.WithNumber("deltaX", mcp.Description("Horizontal wheel delta for precise scrolling")),
mcp.WithNumber("deltaY", mcp.Description("Vertical wheel delta for precise scrolling")),
mcp.WithString("direction", mcp.Description(
"Convenience direction: 'down', 'left', 'right' or 'up'. Moves "+scrollStepDescription+
" per step, the same distance as the CLI's `pinchtab scroll <direction>`; multiply it with 'steps' or override it with 'pixels'. "+
"With a selector or nodeId it scrolls that far INSIDE the element (wheel semantics) rather than revealing it. "+
"It cannot be combined with deltaX/deltaY, which set their own magnitude.")),
mcp.WithNumber("steps", mcp.Description("Multiplier for direction-based scrolling (default 1), so steps=2 moves twice "+scrollStepDescription)),
mcp.WithNumber("x", mcp.Description("Optional X coordinate for wheel target")),
mcp.WithNumber("y", mcp.Description("Optional Y coordinate for wheel target")),
nodeIDParam(),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_scroll_into_view",
mcp.WithDescription("Scroll a target element into view and return geometry details for stable follow-up actions."),
selectorParam(),
selectorAliasParams(),
queryParam(),
nodeIDParam(),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_fill",
mcp.WithDescription("Fill an input field directly via JavaScript dispatch"),
selectorParam(),
selectorAliasParams(),
queryParam(),
mcp.WithString("value", mcp.Required(), mcp.Description("Value to fill; send an empty string to clear the field")),
stringAliasParam("text", "value"),
nodeIDParam(),
tabIDParam(),
mcp.WithBoolean("snap", mcp.Description("Return interactive compact snapshot after fill (saves a round-trip)")),
browserParam(),
),
mcp.NewTool("pinchtab_key",
mcp.WithDescription("Send keyboard input; 'action' picks which. action='press': press a keyboard key (Enter, Tab, Escape, etc.) — needs 'key'. action='down': hold a key down, e.g. modifier keys like Control, Shift, Alt — needs 'key'. action='up': release a held key — needs 'key'. action='type': type text at the currently focused element via keystroke events (keyDown + keyUp per character) — needs 'text'. action='insert': insert text at the currently focused element without key events (paste-like) — needs 'text'. 'nodeId' is honoured by action='press', which focuses that node before the key is sent."),
mcp.WithString("action", mcp.Required(), mcp.Enum("press", "down", "up", "type", "insert"), mcp.Description("Keyboard action to send")),
mcp.WithString("key", mcp.Description("Key for action press/down/up (e.g. 'Enter', 'Tab', 'Escape', 'Control', 'Shift', 'Alt', 'a')")),
mcp.WithString("text", mcp.Description("Text for action type/insert")),
nodeIDParam(),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_eval",
mcp.WithDescription("Execute JavaScript in the browser and return the result. This is not frame-scoped; current pinchtab_frame state does not change evaluation context. A Promise-returning expression needs awaitPromise:true to resolve, otherwise it returns {} with a hint."),
expressionParam("expression"),
mcp.WithBoolean("awaitPromise", mcp.Description("Resolve a returned Promise before responding, returning its resolved value (matches CLI --await-promise)")),
tabIDParam(),
),
mcp.NewTool("pinchtab_pdf",
mcp.WithDescription("Export the current page as a PDF (returns base64-encoded PDF)"),
tabIDParam(),
mcp.WithBoolean("landscape", mcp.Description("Landscape orientation")),
mcp.WithNumber("scale", mcp.Description("Print scale 0.1-2.0 (default: 1.0)")),
mcp.WithString("pageRanges", mcp.Description("Pages to export (e.g., '1-3,5')")),
),
mcp.NewTool("pinchtab_find",
mcp.WithDescription("Find elements by natural-language query. Returns best_ref and selector hints that should be reused in action tools."),
mcp.WithString("query", mcp.Required(), mcp.Description("Text or CSS selector to search for")),
tabIDParam(),
),
mcp.NewTool("pinchtab_extract",
mcp.WithDescription("Extract typed values from the page against a JSON schema. Prefer it over snapshot-then-parse for structured values; each field returns a ref for action tools. If a field comes back low confidence, pin it with x-pinchtab-hint."),
mcp.WithObject("schema", mcp.Required(), mcp.Description("JSON schema: string/number/integer/boolean properties or arrays of such objects; x-pinchtab-scope pins an array's container")),
tabIDParam(),
mcp.WithString("scope", mcp.Description("Confine all fields to one element's subtree (ref, role:, text: or query)")),
mcp.WithNumber("maxItems", mcp.Description("Cap on items per array (default 100)")),
),
mcp.NewTool("pinchtab_list_tabs",
mcp.WithDescription("List all open browser tabs"),
),
mcp.NewTool("pinchtab_close_tab",
mcp.WithDescription("Close a browser tab"),
tabIDParam(),
),
mcp.NewTool("pinchtab_health",
mcp.WithDescription("Check PinchTab server health status"),
),
mcp.NewTool("pinchtab_handoff",
mcp.WithDescription("Pause a tab for human handoff (a CAPTCHA, a login, a consent wall the agent must not solve). While paused every action tool on that tab is refused with tab_paused_handoff. Return control to the user, ask them to finish in the browser, then call pinchtab_resume. Other tabs are unaffected."),
requiredTabIDParam(),
mcp.WithString("reason", mcp.Description("Why the tab is handed off, e.g. captcha_manual or login_required (default manual_handoff)")),
mcp.WithNumber("timeoutMs", mcp.Description("Optional auto-resume after this many milliseconds; 0 or omitted means the tab stays paused until pinchtab_resume")),
),
mcp.NewTool("pinchtab_resume",
mcp.WithDescription("Resume a tab paused for human handoff so action tools work again. Call it only after the user has confirmed they finished the manual step; check with pinchtab_handoff_status first when unsure."),
requiredTabIDParam(),
mcp.WithString("status", mcp.Description("Optional note recorded with the resume, e.g. completed or failed")),
),
mcp.NewTool("pinchtab_handoff_status",
mcp.WithDescription("Report a tab's handoff state: status paused_handoff with reason, pausedAt and any expiresAt while a human holds it, or status active once resumed or auto-resumed by its timeout."),
requiredTabIDParam(),
),
mcp.NewTool("pinchtab_cookies",
mcp.WithDescription("Get cookies for the current page"),
tabIDParam(),
),
mcp.NewTool("pinchtab_cookies_set",
mcp.WithDescription("Set one cookie on the current page, for reusing an authenticated session. An empty value blanks the cookie without deleting it."),
mcp.WithString("name", mcp.Required(), mcp.Description("Cookie name")),
mcp.WithString("value", mcp.Required(), mcp.Description("Cookie value; an empty string blanks the cookie")),
mcp.WithString("url", mcp.Description("Target URL (default: the tab's current page)")),
mcp.WithString("domain", mcp.Description("Cookie domain")),
mcp.WithString("path", mcp.Description("Cookie path")),
mcp.WithString("sameSite", mcp.Description("SameSite attribute: Strict, Lax or None")),
mcp.WithBoolean("secure", mcp.Description("Mark the cookie Secure")),
mcp.WithBoolean("httpOnly", mcp.Description("Mark the cookie HttpOnly")),
mcp.WithNumber("expires", mcp.Description("Expiry as a Unix timestamp in seconds; omit for a session cookie")),
tabIDParam(),
),
mcp.NewTool("pinchtab_connect_profile",
mcp.WithDescription("Get the user-facing connect URL and instance status for a profile"),
mcp.WithString("profile", mcp.Required(), mcp.Description("Profile name or profile ID")),
),
mcp.NewTool("pinchtab_wait",
mcp.WithDescription("Wait for one condition; 'for' picks which and 'value' carries it. for='ms': wait a specified number of milliseconds (max 30000; needs no browser). for='selector': wait for an element matching a unified selector (CSS, XPath, text, or ref) to appear or disappear on the page — see 'state'. for='text': wait for specific text to appear on the page. for='url': wait for the page URL to match a glob pattern (e.g. '**/dashboard'). for='load': wait for a page load state — 'ready-state' (readyState=complete), 'content-loaded' (readyState in {interactive, complete}), or 'network-idle' (0 in-flight requests for 500ms). for='function': wait for a JavaScript expression to return a truthy value."),
mcp.WithString("for", mcp.Required(), mcp.Enum("ms", "selector", "text", "url", "load", "function"), mcp.Description("What to wait for")),
mcp.WithString("value", mcp.Required(), mcp.Description("What to wait for, read as 'for' says: a millisecond count, a selector, page text, a URL glob pattern, a load state, or a JavaScript expression")),
timeoutMsParam(),
numberAliasParam("timeout", "timeoutMs"),
mcp.WithString("state", mcp.Description("Element state to wait for with for='selector': 'visible' (default) or 'hidden'")),
tabIDParam(),
browserParam(),
),
mcp.NewTool("pinchtab_network",
mcp.WithDescription("List recent network requests captured from the browser. Returns method, status, URL, type, size, and timing for each request."),
tabIDParam(),
mcp.WithString("filter", mcp.Description("URL pattern filter (substring match)")),
mcp.WithString("method", mcp.Description("HTTP method filter (GET, POST, etc)")),
mcp.WithString("status", mcp.Description("Status code range filter (e.g. '4xx', '5xx', '200')")),
mcp.WithString("type", mcp.Description("Resource type filter (xhr, fetch, document, stylesheet, script, image, etc)")),
mcp.WithNumber("limit", mcp.Description("Maximum number of entries to return")),
mcp.WithNumber("bufferSize", mcp.Description("Per-tab buffer size for new capture (default from config, typically 100)")),
),
mcp.NewTool("pinchtab_network_detail",
mcp.WithDescription("Get full details of a specific network request including headers, timing, and optionally the response body"),
mcp.WithString("requestId", mcp.Required(), mcp.Description("The request ID from pinchtab_network results")),
tabIDParam(),
mcp.WithBoolean("body", mcp.Description("Include response body (can be large)")),
),
mcp.NewTool("pinchtab_network_clear",
mcp.WithDescription("Clear captured network data for a tab or all tabs"),
mcp.WithString("tabId", mcp.Description("Target tab ID (optional, clears all if empty)")),
),
mcp.NewTool("pinchtab_network_route",
mcp.WithDescription("Install a request interception rule on a tab. Action 'abort' blocks matching requests, 'fulfill' returns a mocked response body, 'continue' passes through. Fulfill is BLOCKED on hosts in security.allowedDomains (the operator's authorized/sensitive surfaces) and ALLOWED on other hosts; matched fulfill rules on allowlisted hosts fall through to a real network fetch."),
requiredTabIDParam(),
mcp.WithString("pattern", mcp.Required(), mcp.Description("URL pattern: substring (no wildcards) or glob ('*', '?')")),
mcp.WithString("action", mcp.Description("'continue' (default), 'abort', or 'fulfill'")),
mcp.WithString("body", mcp.Description("Response body (with action=fulfill). Sent verbatim; not auto-encoded.")),
mcp.WithString("contentType", mcp.Description("Response Content-Type for fulfill (default application/json)")),
mcp.WithNumber("status", mcp.Description("Response status code for fulfill (default 200)")),
mcp.WithString("resourceType", mcp.Description("Limit to a CDP resource category (e.g. script, image, xhr, fetch, stylesheet)")),
mcp.WithString("method", mcp.Description("Limit to an HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS). Fulfill rules without method skip OPTIONS preflights to avoid breaking or bypassing CORS.")),
),
mcp.NewTool("pinchtab_network_unroute",
mcp.WithDescription("Remove a tab's interception rule by pattern, or all rules if pattern is omitted"),
requiredTabIDParam(),
mcp.WithString("pattern", mcp.Description("Pattern to remove (omit to clear all rules)")),
),
mcp.NewTool("pinchtab_network_rules",
mcp.WithDescription("List the interception rules installed on a tab: returns {tabId, rules:[{pattern, action, ...}]} where action is continue, abort or fulfill (with body, contentType, status, resourceType or method when set). Rules survive navigation, so check this on a tab you did not set up; an empty rules list means the tab mocks and blocks nothing."),
requiredTabIDParam(),
),
mcp.NewTool("pinchtab_console",
mcp.WithDescription("Read the tab's captured browser console logs (console.log/warn/error and friends). Check this when a page looks healthy in the snapshot but does not respond to actions — the log often says why. A payload full of error-level logs is still a successful call."),
tabIDParam(),
mcp.WithBoolean("clear", mcp.Description("Clear the tab's console log buffer instead of reading it")),
),
mcp.NewTool("pinchtab_errors",
mcp.WithDescription("Read the tab's uncaught JavaScript errors (exceptions the page threw). Check this when a snapshot looks right but clicks do nothing: a script that died on load leaves the DOM present and the handlers unwired. A payload full of errors is still a successful call."),
tabIDParam(),
mcp.WithBoolean("clear", mcp.Description("Clear the tab's error buffer instead of reading it")),
),
mcp.NewTool("pinchtab_record",
mcp.WithDescription("Record browser activity; 'action' picks which. action='start': start recording — requires security.allowScreencast, and GIF works without ffmpeg while WebM/MP4 need ffmpeg. action='stop': stop recording and save the encoded file; encoding may take a while for long recordings. action='status': check active recording status (format, fps, duration, frame count)."),
mcp.WithString("action", mcp.Required(), mcp.Enum("start", "stop", "status"), mcp.Description("Recording action to take")),
mcp.WithString("file", mcp.Description("Output file path for action start/stop (.gif, .webm, or .mp4); the format is read from the extension, and stop must be given the same path start was")),
mcp.WithNumber("fps", mcp.Description("Frames per second 1-30 (default: 5)")),
mcp.WithNumber("quality", mcp.Description("JPEG capture quality 1-100 (default: 80)")),
mcp.WithNumber("scale", mcp.Description("Resolution scale 0-1.0 (default: 1.0)")),
tabIDParam(),
),
mcp.NewTool("pinchtab_dialog",
mcp.WithDescription("Handle a JavaScript dialog (alert, confirm, prompt). Accept or dismiss the currently open dialog."),
mcp.WithString("action", mcp.Required(), mcp.Description("Action to take: 'accept' or 'dismiss'")),
mcp.WithString("text", mcp.Description("Text to enter for prompt dialogs (only used with accept)")),
tabIDParam(),
),
mcp.NewTool("pinchtab_scrape",
mcp.WithDescription("Scrape a whole site into a page tree of markdown. Pages are discovered and extracted over plain HTTP first (SeaPortal: sitemap/link crawl, URL-pattern sampling); only pages whose HTTP extraction is thin, blocked, or failed are re-rendered in the real browser, so JS-only content still lands. Each page records its content source (http|browser) and routing verdict. For a LARGE site, first call with preview=true for a cheap outline (titles, sizes, snippets, routing verdicts — no bodies, no browser), then expand the pages you want with only=<comma-separated urls>. Full reports can be large, so prefer preview then only over scraping everything."),
mcp.WithString("url", mcp.Required(), mcp.Description("Site URL to crawl (discovery seeds from this host's root)")),
mcp.WithBoolean("preview", mcp.Description("Outline only: page tree, sizes (charCount), and snippets — no browser rendering or full bodies. Survey a large site before expanding.")),
mcp.WithString("only", mcp.Description("Comma-separated URLs to expand at full fidelity instead of crawling — the drill-down after a preview")),
mcp.WithNumber("maxPages", mcp.Description("Maximum pages sampled across the site (default 50)")),
mcp.WithNumber("maxPerPattern", mcp.Description("Maximum pages sampled per URL-pattern group (default 8)")),
mcp.WithString("include", mcp.Description("Comma-separated regexes; only crawl URLs matching one")),
mcp.WithString("exclude", mcp.Description("Comma-separated regexes; skip URLs matching one")),
mcp.WithNumber("concurrency", mcp.Description("Pages browser-rendered in parallel (default 2, max 8)")),
mcp.WithBoolean("enrichAll", mcp.Description("Browser-render every reachable page, ignoring routing")),
mcp.WithBoolean("noBrowser", mcp.Description("HTTP crawl only; record routing verdicts without browser rendering")),
mcp.WithNumber("timeoutSeconds", mcp.Description("Overall HTTP crawl budget in SECONDS (default 60); unlike the millisecond timeoutMs of pinchtab_wait and pinchtab_handoff")),
browserParam(),
),
a11yAuditTool(),
memoryTool(),
memorySnapshotTool(),
memoryCompareTool(),
}
}