mcp-scraper 0.3.16 → 0.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -58
- package/dist/bin/api-server.cjs +418 -53
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +2 -2
- package/dist/bin/mcp-scraper-cli.cjs +4 -4
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +5 -5
- package/dist/bin/mcp-scraper-cli.js.map +1 -1
- package/dist/bin/mcp-scraper-install.cjs +12 -12
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +3 -3
- package/dist/bin/mcp-scraper-install.js.map +1 -1
- package/dist/bin/mcp-stdio-server.cjs +2554 -781
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +1377 -9
- package/dist/bin/mcp-stdio-server.js.map +1 -1
- package/dist/bin/paa-harvest.js +2 -3
- package/dist/bin/paa-harvest.js.map +1 -1
- package/dist/{chunk-7XARJHS6.js → chunk-2XCNU22L.js} +332 -13
- package/dist/chunk-2XCNU22L.js.map +1 -0
- package/dist/chunk-C7ZNIXOA.js +7 -0
- package/dist/chunk-C7ZNIXOA.js.map +1 -0
- package/dist/{chunk-ACIUCZ27.js → chunk-DE7WP4UU.js} +11 -11
- package/dist/chunk-DE7WP4UU.js.map +1 -0
- package/dist/{chunk-ZAUMSBV3.js → chunk-HDPWLYK7.js} +6 -6
- package/dist/{chunk-4OPKIDON.js → chunk-IGOEAKC7.js} +4 -6
- package/dist/{chunk-4OPKIDON.js.map → chunk-IGOEAKC7.js.map} +1 -1
- package/dist/{chunk-M2S27J6Z.js → chunk-ZAP7MYVO.js} +26 -1
- package/dist/chunk-ZAP7MYVO.js.map +1 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/{server-LPVBSE2E.js → server-3M3XCVOT.js} +328 -157
- package/dist/server-3M3XCVOT.js.map +1 -0
- package/dist/{worker-2WVKKCC7.js → worker-J6I5XP2F.js} +9 -10
- package/dist/{worker-2WVKKCC7.js.map → worker-J6I5XP2F.js.map} +1 -1
- package/docs/mcp-tool-manifest.generated.json +28 -27
- package/package.json +3 -3
- package/dist/bin/browser-agent-stdio-server.cjs +0 -1523
- package/dist/bin/browser-agent-stdio-server.cjs.map +0 -1
- package/dist/bin/browser-agent-stdio-server.d.cts +0 -1
- package/dist/bin/browser-agent-stdio-server.d.ts +0 -1
- package/dist/bin/browser-agent-stdio-server.js +0 -43
- package/dist/bin/browser-agent-stdio-server.js.map +0 -1
- package/dist/bin/mcp-scraper-combined-stdio-server.cjs +0 -5601
- package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +0 -1
- package/dist/bin/mcp-scraper-combined-stdio-server.d.cts +0 -1
- package/dist/bin/mcp-scraper-combined-stdio-server.d.ts +0 -1
- package/dist/bin/mcp-scraper-combined-stdio-server.js +0 -70
- package/dist/bin/mcp-scraper-combined-stdio-server.js.map +0 -1
- package/dist/chunk-3YGKXXUG.js +0 -133
- package/dist/chunk-3YGKXXUG.js.map +0 -1
- package/dist/chunk-7XARJHS6.js.map +0 -1
- package/dist/chunk-ACIUCZ27.js.map +0 -1
- package/dist/chunk-ISZWGIWL.js +0 -1332
- package/dist/chunk-ISZWGIWL.js.map +0 -1
- package/dist/chunk-M2S27J6Z.js.map +0 -1
- package/dist/chunk-SOMBZK3V.js +0 -7
- package/dist/chunk-SOMBZK3V.js.map +0 -1
- package/dist/chunk-WN7PBKMV.js +0 -28
- package/dist/chunk-WN7PBKMV.js.map +0 -1
- package/dist/server-LPVBSE2E.js.map +0 -1
- /package/dist/{chunk-ZAUMSBV3.js.map → chunk-HDPWLYK7.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../bin/mcp-stdio-server.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { readFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { HttpMcpToolExecutor } from '../src/mcp/http-mcp-tool-executor.js'\nimport { buildPaaExtractorMcpServer } from '../src/mcp/paa-mcp-server.js'\n\nfunction readApiKeyFile(): string | undefined {\n const explicitPath = process.env.MCP_SCRAPER_KEY_PATH?.trim()\n const paths = [explicitPath, join(homedir(), '.mcp-scraper-key')].filter(Boolean) as string[]\n for (const path of paths) {\n try {\n const value = readFileSync(path, 'utf8').trim()\n if (value) return value\n } catch {}\n }\n return undefined\n}\n\nconst apiKey = (\n process.env.MCP_SCRAPER_API_KEY ??\n process.env.MCP_SCRAPER_KEY ??\n process.env.MCP_API_KEY ??\n readApiKeyFile()\n)?.trim()\nif (!apiKey) {\n process.stderr.write('MCP_SCRAPER_API_KEY env var or ~/.mcp-scraper-key is required\\n')\n process.exit(1)\n}\n\nconst baseUrl = process.env.MCP_SCRAPER_BASE_URL?.trim() || process.env.MCP_BASE_URL?.trim() || 'https://mcpscraper.dev'\nconst executor = new HttpMcpToolExecutor(baseUrl, apiKey)\nconst server = buildPaaExtractorMcpServer(executor)\nconst transport = new StdioServerTransport()\n\nasync function main() {\n await server.connect(transport)\n}\n\nmain().catch((err) => {\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;AACA,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,4BAA4B;AAIrC,SAAS,iBAAqC;AAC5C,QAAM,eAAe,QAAQ,IAAI,sBAAsB,KAAK;AAC5D,QAAM,QAAQ,CAAC,cAAc,KAAK,QAAQ,GAAG,kBAAkB,CAAC,EAAE,OAAO,OAAO;AAChF,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,YAAM,QAAQ,aAAa,MAAM,MAAM,EAAE,KAAK;AAC9C,UAAI,MAAO,QAAO;AAAA,IACpB,QAAQ;AAAA,IAAC;AAAA,EACX;AACA,SAAO;AACT;AAEA,IAAM,UACJ,QAAQ,IAAI,uBACZ,QAAQ,IAAI,mBACZ,QAAQ,IAAI,eACZ,eAAe,IACd,KAAK;AACR,IAAI,CAAC,QAAQ;AACX,UAAQ,OAAO,MAAM,iEAAiE;AACtF,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,UAAU,QAAQ,IAAI,sBAAsB,KAAK,KAAK,QAAQ,IAAI,cAAc,KAAK,KAAK;AAChG,IAAM,WAAW,IAAI,oBAAoB,SAAS,MAAM;AACxD,IAAM,SAAS,2BAA2B,QAAQ;AAClD,IAAM,YAAY,IAAI,qBAAqB;AAE3C,eAAe,OAAO;AACpB,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../bin/mcp-stdio-server.ts","../../src/mcp/browser-agent-mcp-server.ts","../../src/mcp/browser-agent-tool-schemas.ts","../../src/mcp/replay-annotator.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { readFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { HttpMcpToolExecutor } from '../src/mcp/http-mcp-tool-executor.js'\nimport { registerBrowserAgentMcpTools } from '../src/mcp/browser-agent-mcp-server.js'\nimport { registerPaaExtractorMcpTools } from '../src/mcp/paa-mcp-server.js'\nimport { SERVER_INSTRUCTIONS } from '../src/mcp/server-instructions.js'\nimport { renderInstallTerminal } from '../src/install-terminal.js'\nimport { PACKAGE_VERSION } from '../src/version.js'\n\nconst forceStdio =\n process.argv.includes('--stdio') ||\n process.env.MCP_SCRAPER_FORCE_STDIO === '1'\nconst interactiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY)\nconst wantsHelp = process.argv.includes('--help') || process.argv.includes('-h')\n\nif (!forceStdio && (interactiveTerminal || wantsHelp)) {\n const noColor =\n process.argv.includes('--no-color') ||\n process.env.NO_COLOR !== undefined ||\n process.env.FORCE_COLOR === '0' ||\n !process.stdout.isTTY\n\n process.stdout.write(renderInstallTerminal({\n version: PACKAGE_VERSION,\n color: !noColor,\n apiKeyConfigured: Boolean(process.env.MCP_SCRAPER_API_KEY?.trim()),\n }))\n process.exit(0)\n}\n\nfunction readApiKeyFile(): string | undefined {\n const explicitPath = process.env.MCP_SCRAPER_KEY_PATH?.trim()\n const paths = [explicitPath, join(homedir(), '.mcp-scraper-key')].filter(Boolean) as string[]\n for (const path of paths) {\n try {\n const value = readFileSync(path, 'utf8').trim()\n if (value) return value\n } catch {\n void 0\n }\n }\n return undefined\n}\n\nconst apiKey = (\n process.env.MCP_SCRAPER_API_KEY ??\n process.env.MCP_SCRAPER_KEY ??\n process.env.MCP_API_KEY ??\n readApiKeyFile()\n)?.trim()\nif (!apiKey) {\n process.stderr.write('MCP_SCRAPER_API_KEY env var or ~/.mcp-scraper-key is required\\n')\n process.exit(1)\n}\n\nconst baseUrl = process.env.MCP_SCRAPER_BASE_URL?.trim() || process.env.MCP_BASE_URL?.trim() || 'https://mcpscraper.dev'\nconst consoleBaseUrl = process.env.BROWSER_AGENT_CONSOLE_URL?.trim() || baseUrl\nconst server = new McpServer({ name: 'mcp-scraper', version: PACKAGE_VERSION }, { instructions: SERVER_INSTRUCTIONS })\n\nregisterPaaExtractorMcpTools(server, new HttpMcpToolExecutor(baseUrl, apiKey))\nregisterBrowserAgentMcpTools(server, { baseUrl, apiKey, consoleBaseUrl })\n\nconst transport = new StdioServerTransport()\n\nasync function main() {\n await server.connect(transport)\n}\n\nmain().catch(err => {\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`)\n process.exit(1)\n})\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { browserServiceProfileName, browserServiceProfileSaveChanges } from '../lib/browser-service-env.js'\nimport { exportFanout } from '../services/fanout/export.js'\nimport type { EnrichedFanout } from '../services/fanout/classify.js'\nimport { PACKAGE_VERSION } from '../version.js'\nimport {\n BrowserOpenInputSchema,\n BrowserProfileConnectInputSchema,\n BrowserProfileListInputSchema,\n BrowserCaptureFanoutInputSchema,\n BrowserCaptureFanoutOutputSchema,\n BrowserSessionInputSchema,\n BrowserLocateInputSchema,\n BrowserGotoInputSchema,\n BrowserClickInputSchema,\n BrowserTypeInputSchema,\n BrowserScrollInputSchema,\n BrowserPressInputSchema,\n BrowserReplayStopInputSchema,\n BrowserReplayDownloadInputSchema,\n BrowserReplayMarkInputSchema,\n BrowserReplayAnnotateInputSchema,\n BrowserListInputSchema,\n BrowserOpenOutputSchema,\n BrowserScreenshotOutputSchema,\n BrowserReadOutputSchema,\n BrowserLocateOutputSchema,\n BrowserActionOutputSchema,\n BrowserReplayStartOutputSchema,\n BrowserReplayStopOutputSchema,\n BrowserListReplaysOutputSchema,\n BrowserReplayDownloadOutputSchema,\n BrowserReplayMarkOutputSchema,\n BrowserReplayAnnotateOutputSchema,\n BrowserCloseOutputSchema,\n BrowserListSessionsOutputSchema,\n BrowserProfileConnectOutputSchema,\n BrowserProfileListOutputSchema,\n} from './browser-agent-tool-schemas.js'\nimport { annotateReplayVideo } from './replay-annotator.js'\nimport { sanitizeOutboundDiagnostics } from '../api/outbound-sanitize.js'\n\nexport interface BrowserAgentHttpOptions {\n baseUrl: string\n apiKey: string\n consoleBaseUrl?: string\n timeoutMs?: number\n}\n\nfunction structuredResult(value: Record<string, unknown>, isError = false): CallToolResult {\n const safe = sanitizeOutboundDiagnostics(value)\n return {\n content: [{ type: 'text', text: JSON.stringify(safe) }],\n structuredContent: safe,\n isError,\n }\n}\n\nfunction errorMessage(value: unknown): string {\n if (value && typeof value === 'object') {\n const data = value as Record<string, unknown>\n if (typeof data.error === 'string') return data.error\n if (typeof data.message === 'string') return data.message\n }\n return typeof value === 'string' ? value : 'Browser Agent request failed'\n}\n\nfunction errorResult(tool: string, value: unknown, sessionId: string | null = null, replayId: string | null = null): CallToolResult {\n return structuredResult({\n ok: false,\n tool,\n session_id: sessionId,\n ...(replayId !== null ? { replay_id: replayId } : {}),\n error: errorMessage(value),\n raw: value && typeof value === 'object' ? value as Record<string, unknown> : { value },\n }, true)\n}\n\nfunction actionResult(\n tool: string,\n sessionId: string,\n ok: boolean,\n data: unknown,\n nextRecommendedTool: string | null = 'browser_screenshot',\n): CallToolResult {\n if (!ok) return errorResult(tool, data, sessionId)\n return structuredResult({\n ok: true,\n tool,\n session_id: sessionId,\n result: data && typeof data === 'object' ? data as Record<string, unknown> : { value: data },\n nextRecommendedTool,\n })\n}\n\nfunction outputBaseDir(): string {\n return process.env.MCP_SCRAPER_OUTPUT_DIR?.trim() || join(homedir(), 'Downloads', 'mcp-scraper')\n}\n\nfunction safeFilePart(value: string): string {\n return value.replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 120) || 'replay'\n}\n\nfunction replayFilePath(sessionId: string, replayId: string, filename?: string): string {\n const requested = filename?.trim()\n const stamp = new Date().toISOString().replace(/[:.]/g, '-')\n const name = requested\n ? safeFilePart(requested).replace(/\\.mp4$/i, '')\n : `${stamp}-${safeFilePart(sessionId)}-${safeFilePart(replayId)}`\n return join(outputBaseDir(), 'browser-replays', `${name}.mp4`)\n}\n\nfunction slugPart(value?: string): string | null {\n const trimmed = value?.trim().toLowerCase()\n if (!trimmed) return null\n return trimmed\n .replace(/^https?:\\/\\//, '')\n .replace(/^www\\./, '')\n .replace(/\\/.*$/, '')\n .replace(/[^a-z0-9._-]+/g, '-')\n .replace(/[._-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\nfunction savedProfileNameFromEmail(email?: string): string | null {\n const value = slugPart(email)\n if (!value) return null\n return value.slice(0, 80) || null\n}\n\nfunction isEnrichedFanout(value: unknown): value is EnrichedFanout {\n if (!value || typeof value !== 'object') return false\n const candidate = value as Partial<EnrichedFanout>\n return (\n typeof candidate.platform === 'string' &&\n typeof candidate.capturedAt === 'string' &&\n typeof candidate.prompt === 'string' &&\n Array.isArray(candidate.queries) &&\n Array.isArray(candidate.browsedUrls) &&\n Array.isArray(candidate.citedUrls) &&\n Array.isArray(candidate.browsedOnly) &&\n Array.isArray(candidate.snippets) &&\n !!candidate.counts &&\n !!candidate.aggregates\n )\n}\n\nfunction annotatedReplayFilePath(sessionId: string, replayId: string, filename?: string): string {\n const requested = filename?.trim()\n if (requested) return replayFilePath(sessionId, replayId, requested)\n const stamp = new Date().toISOString().replace(/[:.]/g, '-')\n return replayFilePath(sessionId, replayId, `${stamp}-${safeFilePart(sessionId)}-${safeFilePart(replayId)}-annotated`)\n}\n\nfunction finiteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value)\n}\n\nfunction expandElementBounds(\n element: { left: number; top: number; width: number; height: number },\n viewport: { width?: number; height?: number } | undefined,\n padding: number,\n) {\n const sourceWidth = finiteNumber(viewport?.width) && viewport!.width > 0 ? viewport!.width : 1920\n const sourceHeight = finiteNumber(viewport?.height) && viewport!.height > 0 ? viewport!.height : 1080\n const left = Math.max(0, element.left - padding)\n const top = Math.max(0, element.top - padding)\n const right = Math.min(sourceWidth, element.left + element.width + padding)\n const bottom = Math.min(sourceHeight, element.top + element.height + padding)\n return {\n left,\n top,\n width: Math.max(1, right - left),\n height: Math.max(1, bottom - top),\n sourceWidth,\n sourceHeight,\n }\n}\n\nexport function buildBrowserAgentMcpServer(opts: BrowserAgentHttpOptions): McpServer {\n const server = new McpServer({ name: 'browser-agent', version: PACKAGE_VERSION })\n registerBrowserAgentMcpTools(server, opts)\n return server\n}\n\nexport function registerBrowserAgentMcpTools(server: McpServer, opts: BrowserAgentHttpOptions): void {\n const baseUrl = opts.baseUrl.replace(/\\/$/, '')\n const consoleBase = (opts.consoleBaseUrl ?? opts.baseUrl).replace(/\\/$/, '')\n const timeoutMs = opts.timeoutMs ?? 90_000\n\n async function req(\n method: string,\n path: string,\n body?: Record<string, unknown>,\n requestTimeoutMs = timeoutMs,\n ): Promise<{ ok: boolean; data: any }> {\n try {\n const res = await fetch(`${baseUrl}${path}`, {\n method,\n headers: { 'Content-Type': 'application/json', 'x-api-key': opts.apiKey },\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(requestTimeoutMs),\n })\n const data = await res.json().catch(() => ({}))\n return { ok: res.ok, data }\n } catch (err) {\n return { ok: false, data: { error: err instanceof Error ? err.message : String(err) } }\n }\n }\n\n async function downloadReplay(\n sessionId: string,\n replayId: string,\n filename?: string,\n ): Promise<{ ok: boolean; data: any }> {\n const path = `/agent/sessions/${encodeURIComponent(sessionId)}/replays/${encodeURIComponent(replayId)}/download`\n try {\n const res = await fetch(`${baseUrl}${path}`, {\n method: 'GET',\n headers: { 'x-api-key': opts.apiKey },\n signal: AbortSignal.timeout(timeoutMs),\n })\n if (!res.ok) {\n const data = await res.json().catch(async () => ({ error: await res.text().catch(() => `HTTP ${res.status}`) }))\n return { ok: false, data }\n }\n const bytes = Buffer.from(await res.arrayBuffer())\n const filePath = replayFilePath(sessionId, replayId, filename)\n mkdirSync(join(outputBaseDir(), 'browser-replays'), { recursive: true })\n writeFileSync(filePath, bytes)\n return {\n ok: true,\n data: {\n replay_id: replayId,\n file_path: filePath,\n bytes: bytes.length,\n mime_type: res.headers.get('content-type') ?? 'video/mp4',\n download_url: `${baseUrl}${path}`,\n },\n }\n } catch (err) {\n return { ok: false, data: { error: err instanceof Error ? err.message : String(err) } }\n }\n }\n\n const annotations = (title: string, readOnly = false) => ({\n title,\n readOnlyHint: readOnly,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n })\n\n function normalizeLogin(conn: any) {\n return {\n connection_id: conn.connection_id ?? null,\n domain: conn.domain,\n status: conn.status,\n account_email: conn.account_email ?? null,\n note: conn.note ?? null,\n watch_url: conn.connection_id && conn.status !== 'AUTHENTICATED' ? `${consoleBase}/console/auth/${conn.connection_id}` : null,\n last_connected_at: conn.last_connected_at ?? null,\n }\n }\n\n async function fetchConnectedLogins(profile: string): Promise<unknown[]> {\n const list = await req('POST', '/agent/profiles/list', { profile })\n return list.ok && Array.isArray(list.data?.connections) ? list.data.connections.map(normalizeLogin) : []\n }\n\n server.registerTool(\n 'browser_profile_connect',\n {\n title: 'Save a Site Login to a Profile',\n description:\n 'Save a logged-in browser session so this server can reuse a site the user is signed into (ChatGPT, Claude, Reddit, or any account-gated site). Returns an mcpscraper.dev watch_url — give it to the user, they sign in once, and the cookies are saved to a named profile for later browser_open calls. ONE profile holds MANY logins: call this again with the SAME profile and a DIFFERENT domain to stack another account (e.g. add claude.ai to a profile that already has chatgpt.com). Pass note to record what each login is. Side effects: opens a short-lived sign-in session and persists cookies to the profile; it does NOT import the user\\'s existing browser cookies (they log in fresh). NOT for one-off scraping of public pages (use extract_url) and NOT a way to drive the browser (use browser_open). Sample asks: \"save my ChatGPT login\", \"connect my Reddit account\", \"add my Claude login to the same profile\". After the user signs in, poll browser_profile_list until the login reads AUTHENTICATED, then browser_open with the profile.',\n inputSchema: BrowserProfileConnectInputSchema,\n outputSchema: BrowserProfileConnectOutputSchema,\n annotations: annotations('Save a Site Login to a Profile'),\n },\n async input => {\n const domain = slugPart(input.domain) || 'chatgpt.com'\n const setupUrl = input.login_url ?? input.url ?? (domain === 'chatgpt.com' ? 'https://chatgpt.com/' : `https://${domain}/`)\n const profile = input.profile?.trim() || savedProfileNameFromEmail(input.email) || browserServiceProfileName()\n if (!profile) {\n return errorResult('browser_profile_connect', {\n error: 'profile or email is required when BROWSER_AGENT_PROFILE_NAME is not available',\n })\n }\n const accountEmail = input.email?.trim() || null\n const note = input.note?.trim() || null\n const open = await req('POST', '/agent/profiles/onboard', {\n label: input.label ?? `Login setup: ${domain} → ${profile}`,\n profile,\n domain,\n login_url: setupUrl,\n ...(accountEmail ? { account_email: accountEmail } : {}),\n ...(note ? { note } : {}),\n })\n if (!open.ok) return errorResult('browser_profile_connect', open.data)\n const connectedLogins = await fetchConnectedLogins(profile).catch(() => [])\n return structuredResult({\n ok: true,\n tool: 'browser_profile_connect',\n session_id: null,\n auth_connection_id: open.data.connection_id,\n watch_url: `${consoleBase}/console/auth/${open.data.connection_id}`,\n live_view_url: null,\n profile,\n domain,\n setup_url: setupUrl,\n account_email: accountEmail,\n note,\n status: open.data.status ?? null,\n flow_status: open.data.flow_status ?? null,\n flow_step: open.data.flow_step ?? null,\n flow_expires_at: open.data.flow_expires_at ?? null,\n post_login_url: open.data.post_login_url ?? null,\n connected_logins: connectedLogins,\n next_steps: [\n `Give the user watch_url so they can sign in to ${domain}.`,\n 'Poll browser_profile_list (with this profile) until the login reads AUTHENTICATED.',\n 'To add another account to this same profile, call browser_profile_connect again with the same profile and a different domain.',\n 'When authenticated, call browser_open with this profile to drive the logged-in session.',\n ],\n raw: open.data,\n })\n },\n )\n\n server.registerTool(\n 'browser_profile_list',\n {\n title: 'List Saved Logins in a Profile',\n description:\n 'List every site login saved in a profile, each with its current auth status (NEEDS_AUTH / AUTHENTICATED), account email, and note. Use it to (1) see what a profile is connected to before opening a session, and (2) poll a just-saved login until it flips to AUTHENTICATED. Read-only, no cost. Pass profile (or email to derive it); narrow with domain or connection_id to poll a single login. Sample asks: \"what\\'s connected in my profile\", \"is my ChatGPT login ready yet\", \"which accounts are saved\". Pairs with browser_profile_connect (which adds logins) and browser_open (which uses them).',\n inputSchema: BrowserProfileListInputSchema,\n outputSchema: BrowserProfileListOutputSchema,\n annotations: annotations('List Saved Logins in a Profile', true),\n },\n async input => {\n const profile = input.profile?.trim() || savedProfileNameFromEmail(input.email) || browserServiceProfileName()\n if (!profile) {\n return errorResult('browser_profile_list', {\n error: 'profile or email is required when BROWSER_AGENT_PROFILE_NAME is not available',\n })\n }\n const domain = slugPart(input.domain) || undefined\n const res = await req('POST', '/agent/profiles/list', {\n profile,\n ...(domain ? { domain } : {}),\n ...(input.connection_id ? { connection_id: input.connection_id } : {}),\n })\n if (!res.ok) return errorResult('browser_profile_list', res.data)\n const connections = (Array.isArray(res.data?.connections) ? res.data.connections : []).map(normalizeLogin)\n return structuredResult({\n ok: true,\n tool: 'browser_profile_list',\n session_id: null,\n profile,\n connections,\n count: connections.length,\n })\n },\n )\n\n server.registerTool(\n 'browser_open',\n {\n title: 'Open Browser Session',\n description:\n 'Open a direct no-proxy hosted browser session you can drive. Pass a saved profile name to load a session that is already logged into the sites saved in that profile (one profile can hold several logins). To set up or refresh a login first, use browser_profile_connect, then poll browser_profile_list until it reads AUTHENTICATED. Returns a session_id used by all other browser_* tools.',\n inputSchema: BrowserOpenInputSchema,\n outputSchema: BrowserOpenOutputSchema,\n annotations: annotations('Open Browser Session'),\n },\n async input => {\n const profile = input.profile ?? browserServiceProfileName()\n const saveProfileChanges = input.save_profile_changes ?? browserServiceProfileSaveChanges()\n const open = await req('POST', '/agent/sessions', {\n label: input.label,\n ...(profile ? { profile } : {}),\n ...(profile && typeof saveProfileChanges === 'boolean' ? { save_profile_changes: saveProfileChanges } : {}),\n disable_default_proxy: true,\n timeout_seconds: input.timeout_seconds,\n ...(input.url ? { url: input.url } : {}),\n })\n if (!open.ok) return errorResult('browser_open', open.data)\n const session = open.data\n return structuredResult({\n ok: true,\n tool: 'browser_open',\n session_id: session.session_id,\n watch_url: `${consoleBase}/console/${session.session_id}`,\n live_view_url: null,\n url: input.url ?? null,\n hint: 'Call browser_screenshot to see the page. Click by the x,y of an element from the snapshot.',\n raw: session,\n })\n },\n )\n\n server.registerTool(\n 'browser_screenshot',\n {\n title: 'See Page (Screenshot + Elements)',\n description:\n 'Capture what the browser currently shows. Returns a screenshot image PLUS a text snapshot listing interactive elements with their center x,y coordinates, the page url and title, and visible text. This is your primary way to perceive the page. Click elements by their listed x,y. If a Cloudflare/CAPTCHA challenge is visible, wait and screenshot again rather than clicking it.',\n inputSchema: BrowserSessionInputSchema,\n outputSchema: BrowserScreenshotOutputSchema,\n annotations: annotations('See Page', true),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/screenshot`)\n if (!res.ok) return errorResult('browser_screenshot', res.data, input.session_id)\n const { image_base64, mime_type, url, title, elements, text } = res.data\n const content: CallToolResult['content'] = []\n if (image_base64) content.push({ type: 'image', data: image_base64, mimeType: mime_type ?? 'image/png' })\n const structured = {\n ok: true,\n tool: 'browser_screenshot',\n session_id: input.session_id,\n url: url ?? null,\n title: title ?? null,\n text: typeof text === 'string' ? text : '',\n elements: Array.isArray(elements) ? elements : [],\n screenshot: image_base64 ? { mime_type: mime_type ?? 'image/png', inline: true } : null,\n }\n content.push({\n type: 'text',\n text: JSON.stringify(structured),\n })\n return { content, structuredContent: structured }\n },\n )\n\n server.registerTool(\n 'browser_read',\n {\n title: 'Read Page Text + Elements',\n description:\n 'Return the page url, title, visible text, and the list of interactive elements (with x,y) without an image. Cheaper than browser_screenshot when you only need to read content or find a target element to click.',\n inputSchema: BrowserSessionInputSchema,\n outputSchema: BrowserReadOutputSchema,\n annotations: annotations('Read Page', true),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/read`)\n if (!res.ok) return errorResult('browser_read', res.data, input.session_id)\n return structuredResult({\n ok: true,\n tool: 'browser_read',\n session_id: input.session_id,\n url: res.data?.url ?? null,\n title: res.data?.title ?? null,\n text: typeof res.data?.text === 'string' ? res.data.text : '',\n elements: Array.isArray(res.data?.elements) ? res.data.elements : [],\n raw: res.data,\n })\n },\n )\n\n server.registerTool(\n 'browser_locate',\n {\n title: 'Locate DOM Targets',\n description:\n 'Locate exact visible DOM elements or text ranges in the current browser viewport and return left/top/width/height bounds in screenshot pixels. Use this before drawing annotations or when a callout must literally circle, box, underline, or point to a real element. Prefer CSS selectors for exact UI elements; use text when selector is unknown. When a replay is actively recording, the result includes replay_elapsed_seconds for timing.',\n inputSchema: BrowserLocateInputSchema,\n outputSchema: BrowserLocateOutputSchema,\n annotations: annotations('Locate DOM Targets', true),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/locate`, { targets: input.targets })\n if (!res.ok) return errorResult('browser_locate', res.data, input.session_id)\n return structuredResult({\n ok: true,\n tool: 'browser_locate',\n session_id: input.session_id,\n url: res.data?.url ?? null,\n title: res.data?.title ?? null,\n viewport: res.data?.viewport ?? null,\n replay: res.data?.replay ?? null,\n targets: Array.isArray(res.data?.targets) ? res.data.targets : [],\n raw: res.data,\n })\n },\n )\n\n server.registerTool(\n 'browser_goto',\n {\n title: 'Navigate To URL',\n description: 'Navigate an existing browser session to a URL when the user asks you to go to another page or continue browsing in the same session. Use browser_open first if no session exists. Follow with browser_screenshot to see redirects, login walls, CAPTCHA/Cloudflare state, or the loaded page.',\n inputSchema: BrowserGotoInputSchema,\n outputSchema: BrowserActionOutputSchema,\n annotations: annotations('Navigate To URL'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/goto`, { url: input.url })\n return actionResult('browser_goto', input.session_id, res.ok, res.data, 'browser_screenshot')\n },\n )\n\n server.registerTool(\n 'browser_click',\n {\n title: 'Click',\n description: 'Click a visible page target using screenshot pixel coordinates. Use this when the user asks you to press a button, open a menu, choose a result, or activate a visible UI element. Use x/y only from the latest browser_screenshot, browser_read, or browser_locate result; do not guess coordinates. Follow with browser_screenshot when the click may change the page.',\n inputSchema: BrowserClickInputSchema,\n outputSchema: BrowserActionOutputSchema,\n annotations: annotations('Click'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/click`, {\n x: input.x,\n y: input.y,\n button: input.button,\n num_clicks: input.num_clicks,\n })\n return actionResult('browser_click', input.session_id, res.ok, res.data, 'browser_screenshot')\n },\n )\n\n server.registerTool(\n 'browser_type',\n {\n title: 'Type Text',\n description: 'Type text into the currently focused browser field. Use this when the user asks you to fill a search box, form field, login field, or editable text area. Click or Tab to the field first if focus is uncertain. Use browser_press with [\"Return\"] to submit, and browser_screenshot afterward when page state matters.',\n inputSchema: BrowserTypeInputSchema,\n outputSchema: BrowserActionOutputSchema,\n annotations: annotations('Type Text'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/type`, { text: input.text, delay: input.delay })\n return actionResult('browser_type', input.session_id, res.ok, res.data, 'browser_screenshot')\n },\n )\n\n server.registerTool(\n 'browser_scroll',\n {\n title: 'Scroll',\n description: 'Scroll the page to reveal more content before reading, clicking, or locating elements. Positive delta_y scrolls down; negative delta_y scrolls up. Follow with browser_screenshot or browser_read to inspect newly revealed content.',\n inputSchema: BrowserScrollInputSchema,\n outputSchema: BrowserActionOutputSchema,\n annotations: annotations('Scroll'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/scroll`, {\n delta_y: input.delta_y,\n delta_x: input.delta_x,\n x: input.x,\n y: input.y,\n })\n return actionResult('browser_scroll', input.session_id, res.ok, res.data, 'browser_screenshot')\n },\n )\n\n server.registerTool(\n 'browser_press',\n {\n title: 'Press Keys',\n description: 'Press keyboard keys or combinations in the active browser session. Use this for submit, Escape, Tab navigation, select-all, or keyboard shortcuts. Examples: [\"Return\"], [\"Escape\"], [\"Tab\"], [\"Ctrl+a\"], [\"Ctrl+Shift+Tab\"]. Use browser_type for text entry and browser_screenshot after keypresses that may change the page.',\n inputSchema: BrowserPressInputSchema,\n outputSchema: BrowserActionOutputSchema,\n annotations: annotations('Press Keys'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/press`, { keys: input.keys })\n return actionResult('browser_press', input.session_id, res.ok, res.data, 'browser_screenshot')\n },\n )\n\n server.registerTool(\n 'browser_replay_start',\n {\n title: 'Start Recording',\n description: 'Start recording an MP4 replay of the session. Returns replay_id, view_url when available, and a download_url. Use to capture a task for later review; stop with browser_replay_stop.',\n inputSchema: BrowserSessionInputSchema,\n outputSchema: BrowserReplayStartOutputSchema,\n annotations: annotations('Start Recording'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/replay/start`)\n if (!res.ok) return errorResult('browser_replay_start', res.data, input.session_id)\n return structuredResult({\n ok: true,\n tool: 'browser_replay_start',\n session_id: input.session_id,\n replay_id: res.data?.replay_id ?? res.data?.replayId ?? null,\n view_url: res.data?.view_url ?? res.data?.viewUrl ?? null,\n download_url: res.data?.download_url ?? res.data?.downloadUrl ?? null,\n raw: res.data,\n })\n },\n )\n\n server.registerTool(\n 'browser_replay_stop',\n {\n title: 'Stop Recording',\n description: 'Stop a replay recording and expose the final view_url and download_url. Use browser_replay_download to save the MP4 to the configured output directory.',\n inputSchema: BrowserReplayStopInputSchema,\n outputSchema: BrowserReplayStopOutputSchema,\n annotations: annotations('Stop Recording'),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/replay/stop`, { replay_id: input.replay_id })\n if (!res.ok) return errorResult('browser_replay_stop', res.data, input.session_id, input.replay_id)\n return structuredResult({\n ok: true,\n tool: 'browser_replay_stop',\n session_id: input.session_id,\n replay_id: res.data?.replay_id ?? res.data?.replayId ?? input.replay_id,\n view_url: res.data?.view_url ?? res.data?.viewUrl ?? null,\n download_url: res.data?.download_url ?? res.data?.downloadUrl ?? null,\n raw: res.data,\n })\n },\n )\n\n server.registerTool(\n 'browser_list_replays',\n {\n title: 'List Replay Videos',\n description: 'List replay recordings for a browser session, including final view_url and authenticated download_url values when available.',\n inputSchema: BrowserSessionInputSchema,\n outputSchema: BrowserListReplaysOutputSchema,\n annotations: annotations('List Replay Videos', true),\n },\n async input => {\n const res = await req('GET', `/agent/sessions/${input.session_id}/replays`)\n if (!res.ok) return errorResult('browser_list_replays', res.data, input.session_id)\n const replays = Array.isArray(res.data?.replays) ? res.data.replays : []\n return structuredResult({\n ok: true,\n tool: 'browser_list_replays',\n session_id: input.session_id,\n replays,\n count: replays.length,\n })\n },\n )\n\n server.registerTool(\n 'browser_replay_download',\n {\n title: 'Download Replay MP4',\n description: 'Download a replay recording through MCP Scraper and save the MP4 under MCP_SCRAPER_OUTPUT_DIR/browser-replays. Use after browser_replay_stop or browser_list_replays.',\n inputSchema: BrowserReplayDownloadInputSchema,\n outputSchema: BrowserReplayDownloadOutputSchema,\n annotations: annotations('Download Replay MP4'),\n },\n async input => {\n const res = await downloadReplay(input.session_id, input.replay_id, input.filename)\n if (!res.ok) return errorResult('browser_replay_download', res.data, input.session_id, input.replay_id)\n return structuredResult({\n ok: true,\n tool: 'browser_replay_download',\n session_id: input.session_id,\n replay_id: input.replay_id,\n file_path: res.data?.file_path ?? null,\n bytes: typeof res.data?.bytes === 'number' ? res.data.bytes : null,\n mime_type: res.data?.mime_type ?? null,\n download_url: res.data?.download_url ?? null,\n })\n },\n )\n\n server.registerTool(\n 'browser_replay_mark',\n {\n title: 'Mark Replay Annotation',\n description:\n 'While a replay is actively recording, locate one exact DOM target and return a ready-to-use annotation object with DOM bounds and replay-relative timing. Use this instead of guessing start_seconds or drawing rough rectangles. Workflow: start browser_replay_start, navigate until the target is visible and stable, call browser_replay_mark for each callout, then stop the replay and pass the returned annotations to browser_replay_annotate.',\n inputSchema: BrowserReplayMarkInputSchema,\n outputSchema: BrowserReplayMarkOutputSchema,\n annotations: annotations('Mark Replay Annotation', true),\n },\n async input => {\n const res = await req('POST', `/agent/sessions/${input.session_id}/locate`, { targets: [input.target] })\n if (!res.ok) return errorResult('browser_replay_mark', res.data, input.session_id)\n const target = res.data?.targets?.[0]\n const element = target?.element\n const elapsed = res.data?.replay?.replay_elapsed_seconds\n if (!target?.found || !element) {\n return errorResult('browser_replay_mark', { error: target?.error ?? 'target not found in current viewport', target }, input.session_id)\n }\n if (!finiteNumber(elapsed)) {\n return errorResult('browser_replay_mark', { error: 'no active replay clock found; call browser_replay_start before browser_replay_mark' }, input.session_id)\n }\n const padded = expandElementBounds(element, res.data?.viewport, input.padding ?? 8)\n const start = Math.max(0, elapsed + (input.start_offset_seconds ?? -0.25))\n const duration = input.duration_seconds ?? 4\n const annotation = {\n type: input.type ?? 'box',\n start_seconds: Number(start.toFixed(3)),\n end_seconds: Number((start + duration).toFixed(3)),\n left: Math.round(padded.left),\n top: Math.round(padded.top),\n width: Math.round(padded.width),\n height: Math.round(padded.height),\n ...(input.label ? { label: input.label } : {}),\n ...(input.color ? { color: input.color } : {}),\n ...(input.thickness ? { thickness: input.thickness } : {}),\n }\n return structuredResult({\n ok: true,\n tool: 'browser_replay_mark',\n session_id: input.session_id,\n replay_id: res.data?.replay?.replay_id ?? res.data?.replay?.replayId ?? null,\n annotation,\n source_width: padded.sourceWidth,\n source_height: padded.sourceHeight,\n replay: res.data.replay,\n target,\n hint: 'Append annotation to your annotations array. Use source_width/source_height with browser_replay_annotate.',\n })\n },\n )\n\n server.registerTool(\n 'browser_replay_annotate',\n {\n title: 'Annotate Replay MP4',\n description:\n 'Download a browser replay MP4, render visual annotations over it, and save a new annotated MP4 under MCP_SCRAPER_OUTPUT_DIR/browser-replays. Use this after browser_replay_stop when the user wants proof videos with circles, boxes, arrows, underlines, or labels. For accurate timing and placement, prefer annotations returned by browser_replay_mark while the replay is recording; otherwise use exact left/top/width/height bounds from browser_locate. If the replay video size differs from the screenshot coordinate space, pass source_width and source_height.',\n inputSchema: BrowserReplayAnnotateInputSchema,\n outputSchema: BrowserReplayAnnotateOutputSchema,\n annotations: annotations('Annotate Replay MP4'),\n },\n async input => {\n const sourceName = input.filename ? `${input.filename}-source` : undefined\n const downloaded = await downloadReplay(input.session_id, input.replay_id, sourceName)\n if (!downloaded.ok) return errorResult('browser_replay_annotate', downloaded.data, input.session_id, input.replay_id)\n try {\n const sourcePath = String(downloaded.data.file_path)\n const outputPath = annotatedReplayFilePath(input.session_id, input.replay_id, input.filename)\n mkdirSync(join(outputBaseDir(), 'browser-replays'), { recursive: true })\n const result = await annotateReplayVideo(sourcePath, outputPath, {\n annotations: input.annotations,\n sourceWidth: input.source_width,\n sourceHeight: input.source_height,\n sourceLeftOffset: input.source_left_offset,\n sourceTopOffset: input.source_top_offset,\n })\n return structuredResult({\n ok: true,\n tool: 'browser_replay_annotate',\n session_id: input.session_id,\n replay_id: input.replay_id,\n source_file_path: sourcePath,\n annotated_file_path: result.filePath,\n bytes: result.bytes,\n width: result.width,\n height: result.height,\n annotation_count: result.annotationCount,\n mime_type: 'video/mp4',\n })\n } catch (err) {\n return errorResult('browser_replay_annotate', { error: err instanceof Error ? err.message : String(err) }, input.session_id, input.replay_id)\n }\n },\n )\n\n server.registerTool(\n 'browser_close',\n {\n title: 'Close Browser Session',\n description: 'Close and release a browser session when the task is done, when the user asks to stop the browser, or when active browser billing should end. Use browser_list_sessions first if you need to recover the session_id.',\n inputSchema: BrowserSessionInputSchema,\n outputSchema: BrowserCloseOutputSchema,\n annotations: { title: 'Close Browser Session', readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },\n },\n async input => {\n const res = await req('DELETE', `/agent/sessions/${input.session_id}`)\n if (!res.ok) return errorResult('browser_close', res.data, input.session_id)\n return structuredResult({\n ok: true,\n tool: 'browser_close',\n session_id: input.session_id,\n closed: true,\n raw: res.data,\n })\n },\n )\n\n server.registerTool(\n 'browser_list_sessions',\n {\n title: 'List Browser Sessions',\n description: 'List browser sessions and their status, with a watch_url for each. Use this to recover a session_id, find an active browser, or decide which session to close. Use browser_open to create a new session.',\n inputSchema: BrowserListInputSchema,\n outputSchema: BrowserListSessionsOutputSchema,\n annotations: annotations('List Browser Sessions', true),\n },\n async input => {\n const res = await req('GET', `/agent/sessions${input.include_closed ? '?all=1' : ''}`)\n if (!res.ok) return errorResult('browser_list_sessions', res.data)\n const sessions = (res.data.sessions ?? []).map((s: any) => ({ ...s, watch_url: `${consoleBase}/console/${s.session_id}` }))\n return structuredResult({\n ok: true,\n tool: 'browser_list_sessions',\n session_id: null,\n sessions,\n count: sessions.length,\n })\n },\n )\n\n server.registerTool(\n 'query_fanout_workflow',\n {\n title: 'Capture AI Search Fan-Out',\n description:\n 'Capture the query fan-out behind a ChatGPT or Claude web-search answer for Answer Engine Optimization (AEO): the exact sub-queries the model issued, every researched URL split into cited vs browsed-only (with citation frequency and snippet), each source tagged by category (First-party/vendor, News/media, Reddit, Social/video, Encyclopedia, Review site, Docs, Blog), plus top sourced sites and citation order. Set export=true for durable JSON, CSV, TSV, and HTML artifacts; export paths are returned relative to MCP_SCRAPER_OUTPUT_DIR. This returns the raw structured data; YOU analyze it — classify each sub-query by funnel stage (Problem-aware, Solution-aware, Decision-aware, Retention) and type (BoFu, Branded, Comparison, How-to, Search operator), name the brands the model researched, and give AEO insights. Sample asks: \"capture the fan-out for this ChatGPT answer\", \"what did Claude search and cite for best CRM\", \"show the sub-queries and sources behind this AI answer\". WRITE NOTE: passing prompt submits a real message in the user\\'s logged-in account (a new conversation turn) — only send when the user wants that; omit prompt to capture a prompt the user just ran. Setup, if not already connected or if the profile disconnected: call browser_profile_connect, give the user the watch_url, let them complete login, then poll browser_profile_list until status is AUTHENTICATED. After that, browser_open the saved direct no-proxy profile and go to chatgpt.com or claude.ai. Fan-out is captured only as it streams, so the session must be open when the prompt runs. NOT for Google AI Overview citations — use harvest_paa for those; this tool is ChatGPT and Claude only.',\n inputSchema: BrowserCaptureFanoutInputSchema,\n outputSchema: BrowserCaptureFanoutOutputSchema,\n annotations: annotations('Capture AI Search Fan-Out'),\n },\n async input => {\n const emit = (result: Record<string, unknown>, exports: unknown) => structuredResult({\n ok: true,\n tool: 'query_fanout_workflow',\n session_id: input.session_id,\n platform: result.platform,\n captured_at: result.capturedAt,\n prompt: result.prompt,\n meta: result.meta,\n queries: result.queries,\n browsed_urls: result.browsedUrls,\n cited_urls: result.citedUrls,\n browsed_only: result.browsedOnly,\n snippets: result.snippets,\n counts: result.counts,\n aggregates: result.aggregates,\n first_party_domain: result.firstPartyDomain,\n exports: exports ?? null,\n ...(result.debug ? { debug: result.debug } : {}),\n })\n const res = await req('POST', `/agent/sessions/${input.session_id}/capture-fanout`, {\n prompt: input.prompt,\n wait_ms: input.wait_ms,\n first_party_domain: input.first_party_domain,\n reset: input.reset,\n export: input.export,\n }, Math.max(timeoutMs, (input.wait_ms ?? (input.prompt ? 90_000 : 8_000)) + 30_000))\n if (!res.ok) return errorResult('query_fanout_workflow', res.data, input.session_id)\n const hosted = (res.data?.result ?? res.data) as Record<string, unknown>\n let exports = res.data?.exports ?? null\n if (input.export && !exports && isEnrichedFanout(hosted)) {\n try {\n exports = exportFanout(hosted)\n } catch (err) {\n return errorResult(\n 'query_fanout_workflow',\n {\n error: `Fan-out captured but local export failed: ${err instanceof Error ? err.message : String(err)}`,\n result: hosted,\n },\n input.session_id,\n )\n }\n }\n return emit(hosted, exports)\n },\n )\n\n}\n","import { z } from 'zod'\n\nconst NullableString = z.string().nullable()\nconst BrowserRawObject = z.record(z.unknown())\n\nconst BrowserElementOutput = z.record(z.unknown())\n\nconst BrowserBaseOutput = {\n ok: z.boolean().describe('Whether the browser-agent action succeeded.'),\n tool: z.string().describe('Browser Agent MCP tool that produced this response.'),\n session_id: NullableString.describe('Browser session id when the response is scoped to a session.'),\n}\n\nconst BrowserReplayBaseOutput = {\n ...BrowserBaseOutput,\n replay_id: NullableString.describe('Replay id when the response is scoped to a replay.'),\n}\n\nexport const BrowserOpenInputSchema = {\n label: z.string().optional().describe('Optional human label for this session, shown in the watch console.'),\n url: z.string().url().optional().describe('Optional URL to navigate to immediately after opening.'),\n profile: z.string().optional().describe('Optional saved hosted profile name to load a logged-in session for a site.'),\n save_profile_changes: z.boolean().optional().describe('Persist cookies and browser storage back to the named profile when the session is closed. Use this for profile setup or intentional auth refreshes; avoid parallel sessions writing to the same profile.'),\n timeout_seconds: z.number().int().min(60).max(259200).optional().describe('How long the direct no-proxy browser session may live before auto-termination. Defaults to 600. The browser idles into a zero-cost standby between actions, so a longer timeout is cheap.'),\n}\nexport type BrowserOpenInput = z.infer<ReturnType<typeof z.object<typeof BrowserOpenInputSchema>>>\n\nexport const BrowserProfileConnectInputSchema = {\n email: z.string().optional().describe('Account email for the login being saved. Used to derive a stable, reusable profile name AND recorded as a note of who is connected. Does NOT import existing cookies — the user signs in fresh via the returned watch_url.'),\n profile: z.string().optional().describe('Profile to add this login to. Omit to derive one from email. A single profile holds MANY site logins — pass the same profile name again with a different domain to stack another account (e.g. add claude.ai to a profile that already has chatgpt.com).'),\n domain: z.string().optional().describe('Site to log into, e.g. chatgpt.com, claude.ai, reddit.com. Defaults to chatgpt.com. Each domain is a separate login inside the profile.'),\n login_url: z.string().url().optional().describe('Login page for the domain. Defaults to https://<domain>/ (https://chatgpt.com/ when domain is omitted).'),\n url: z.string().url().optional().describe('Deprecated alias for login_url. Use login_url.'),\n note: z.string().optional().describe('Free-text note describing this login, e.g. \"ChatGPT Plus, work account\". Surfaced by browser_profile_list so you can see what the profile holds.'),\n label: z.string().optional().describe('Optional human label for this sign-in setup session.'),\n timeout_seconds: z.number().int().min(60).max(259200).optional().describe('How long the sign-in setup session may live before auto-termination. Defaults to 600.'),\n}\nexport type BrowserProfileConnectInput = z.infer<ReturnType<typeof z.object<typeof BrowserProfileConnectInputSchema>>>\n\nexport const BrowserProfileListInputSchema = {\n profile: z.string().optional().describe('Profile whose saved logins to list. Omit to derive from email.'),\n email: z.string().optional().describe('Account email used to derive the profile name when profile is not given.'),\n domain: z.string().optional().describe('Restrict to one site login, e.g. chatgpt.com. Use this to poll a single login until its status reads AUTHENTICATED.'),\n connection_id: z.string().optional().describe('A specific login connection id returned by browser_profile_connect, to poll just that one.'),\n}\nexport type BrowserProfileListInput = z.infer<ReturnType<typeof z.object<typeof BrowserProfileListInputSchema>>>\n\nexport const BrowserSessionInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n}\nexport type BrowserSessionInput = z.infer<ReturnType<typeof z.object<typeof BrowserSessionInputSchema>>>\n\nexport const BrowserLocateTargetSchema = z.object({\n name: z.string().optional().describe('Optional label for this target, echoed in the result.'),\n selector: z.string().optional().describe('CSS selector for the exact DOM element to locate, for example h1, input[name=\"q\"], or [data-testid=\"result\"].'),\n text: z.string().optional().describe('Visible text to locate when a selector is not known. The tool returns the text range bounds when possible.'),\n match: z.enum(['contains', 'exact']).default('contains').describe('How to match text targets. Defaults to contains.'),\n index: z.number().int().min(0).default(0).describe('Zero-based match index when multiple elements match.'),\n}).refine(value => Boolean(value.selector || value.text), {\n message: 'target requires selector or text',\n})\n\nexport const BrowserLocateInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n targets: z.array(BrowserLocateTargetSchema).min(1).max(20).describe('DOM targets to locate in the current viewport. Use selectors for exact elements, or text for visible text ranges.'),\n}\nexport type BrowserLocateInput = z.infer<ReturnType<typeof z.object<typeof BrowserLocateInputSchema>>>\n\nexport const BrowserGotoInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n url: z.string().url().describe('URL to navigate the browser to.'),\n}\nexport type BrowserGotoInput = z.infer<ReturnType<typeof z.object<typeof BrowserGotoInputSchema>>>\n\nexport const BrowserClickInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n x: z.number().describe('X coordinate to click, in screenshot pixels. Use only coordinates from the latest browser_screenshot, browser_read, or browser_locate result; do not guess.'),\n y: z.number().describe('Y coordinate to click, in screenshot pixels. Use only coordinates from the latest browser_screenshot, browser_read, or browser_locate result; do not guess.'),\n button: z.enum(['left', 'right', 'middle']).default('left').describe('Mouse button.'),\n num_clicks: z.number().int().min(1).max(3).optional().describe('Number of clicks, e.g. 2 for double-click.'),\n}\nexport type BrowserClickInput = z.infer<ReturnType<typeof z.object<typeof BrowserClickInputSchema>>>\n\nexport const BrowserTypeInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n text: z.string().describe('Text to type at the current focus. Click a field first to focus it.'),\n delay: z.number().int().min(0).max(500).optional().describe('Optional per-keystroke delay in ms for human-like typing.'),\n}\nexport type BrowserTypeInput = z.infer<ReturnType<typeof z.object<typeof BrowserTypeInputSchema>>>\n\nexport const BrowserScrollInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n delta_y: z.number().default(5).describe('Vertical scroll in wheel units. Positive scrolls down, negative up.'),\n delta_x: z.number().default(0).describe('Horizontal scroll in wheel units.'),\n x: z.number().optional().describe('X position to scroll at. Defaults to screen center.'),\n y: z.number().optional().describe('Y position to scroll at. Defaults to screen center.'),\n}\nexport type BrowserScrollInput = z.infer<ReturnType<typeof z.object<typeof BrowserScrollInputSchema>>>\n\nexport const BrowserPressInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n keys: z.array(z.string()).min(1).describe('Keys or combinations to press, e.g. [\"Return\"], [\"Ctrl+a\"], [\"Ctrl+Shift+Tab\"].'),\n}\nexport type BrowserPressInput = z.infer<ReturnType<typeof z.object<typeof BrowserPressInputSchema>>>\n\nexport const BrowserReplayStopInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n replay_id: z.string().describe('The replay id returned by browser_replay_start or browser_list_replays. Use only a returned replay_id; do not construct one yourself.'),\n}\nexport type BrowserReplayStopInput = z.infer<ReturnType<typeof z.object<typeof BrowserReplayStopInputSchema>>>\n\nexport const BrowserReplayDownloadInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n replay_id: z.string().describe('The replay id returned by browser_replay_start or browser_list_replays. Use only a returned replay_id; do not construct one yourself.'),\n filename: z.string().optional().describe('Optional local MP4 filename. Defaults to a timestamped replay filename.'),\n}\nexport type BrowserReplayDownloadInput = z.infer<ReturnType<typeof z.object<typeof BrowserReplayDownloadInputSchema>>>\n\nexport const BrowserReplayAnnotationSchema = z.object({\n type: z.enum(['box', 'circle', 'underline', 'arrow', 'label']).default('box').describe('Annotation style to draw over the replay.'),\n start_seconds: z.number().min(0).default(0).describe('When the annotation should appear in the replay.'),\n end_seconds: z.number().min(0).optional().describe('When the annotation should disappear. Defaults to two seconds after start_seconds.'),\n left: z.number().optional().describe('Target left edge in browser screenshot pixels. Use element.left from browser_screenshot/browser_read.'),\n top: z.number().optional().describe('Target top edge in browser screenshot pixels. Use element.top from browser_screenshot/browser_read.'),\n width: z.number().positive().optional().describe('Target width in browser screenshot pixels. Use element.width from browser_screenshot/browser_read.'),\n height: z.number().positive().optional().describe('Target height in browser screenshot pixels. Use element.height from browser_screenshot/browser_read.'),\n x: z.number().optional().describe('Point target x coordinate in browser screenshot pixels when no box is available.'),\n y: z.number().optional().describe('Point target y coordinate in browser screenshot pixels when no box is available.'),\n from_x: z.number().optional().describe('Arrow start x coordinate in browser screenshot pixels. Defaults near the target.'),\n from_y: z.number().optional().describe('Arrow start y coordinate in browser screenshot pixels. Defaults near the target.'),\n to_x: z.number().optional().describe('Arrow target x coordinate in browser screenshot pixels. Defaults to the target box center.'),\n to_y: z.number().optional().describe('Arrow target y coordinate in browser screenshot pixels. Defaults to the target box center.'),\n label: z.string().max(120).optional().describe('Optional text callout to render near the annotation.'),\n color: z.string().regex(/^#?[0-9a-fA-F]{6}$/).optional().describe('Annotation color as hex, for example #ff3b30.'),\n thickness: z.number().min(1).max(24).optional().describe('Stroke thickness in pixels. Defaults to 5.'),\n})\n\nexport const BrowserReplayMarkInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself. A replay must already be recording.'),\n target: BrowserLocateTargetSchema.describe('The exact DOM element or text range to mark in the current viewport.'),\n type: z.enum(['box', 'circle', 'underline', 'arrow']).default('box').describe('Annotation style to generate. Labels are included on the returned annotation when label is provided.'),\n label: z.string().max(120).optional().describe('Optional callout text to render near the target.'),\n color: z.string().regex(/^#?[0-9a-fA-F]{6}$/).optional().describe('Annotation color as hex, for example #ff3b30.'),\n thickness: z.number().min(1).max(24).optional().describe('Stroke thickness in pixels. Defaults to 5.'),\n padding: z.number().min(0).max(80).default(8).describe('Pixels to expand the DOM bounds so the highlight does not touch the text edge.'),\n start_offset_seconds: z.number().min(-5).max(10).default(-0.25).describe('Offset from the current replay time. Negative values make the callout appear just before the mark action is captured.'),\n duration_seconds: z.number().min(0.5).max(30).default(4).describe('How long the generated annotation should remain visible.'),\n}\nexport type BrowserReplayMarkInput = z.infer<ReturnType<typeof z.object<typeof BrowserReplayMarkInputSchema>>>\n\nexport const BrowserReplayAnnotateInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. Use only a returned session_id; do not construct one yourself.'),\n replay_id: z.string().describe('The replay id returned by browser_replay_start or browser_list_replays. Use only a returned replay_id; do not construct one yourself.'),\n annotations: z.array(BrowserReplayAnnotationSchema).min(1).max(50).describe('Timed overlay annotations to render on the replay. Prefer annotations returned by browser_replay_mark; otherwise use exact DOM bounds from browser_locate/browser_screenshot/browser_read.'),\n filename: z.string().optional().describe('Optional output MP4 filename. Defaults to a timestamped annotated replay filename.'),\n source_width: z.number().positive().optional().describe('Width of the screenshot coordinate space used for annotations. Defaults to the replay video width.'),\n source_height: z.number().positive().optional().describe('Height of the coordinate space used for annotations. When this is a page viewport height smaller than the replay video height, the annotator infers the browser chrome top offset.'),\n source_left_offset: z.number().min(0).optional().describe('Optional explicit X offset from annotation coordinates to replay video coordinates. Usually omitted.'),\n source_top_offset: z.number().min(0).optional().describe('Optional explicit Y offset from annotation coordinates to replay video coordinates. Usually omitted because browser chrome offset is inferred when source_height is a page viewport height.'),\n}\nexport type BrowserReplayAnnotateInput = z.infer<ReturnType<typeof z.object<typeof BrowserReplayAnnotateInputSchema>>>\n\nexport const BrowserListInputSchema = {\n include_closed: z.boolean().default(false).describe('Include closed sessions in the list.'),\n}\nexport type BrowserListInput = z.infer<ReturnType<typeof z.object<typeof BrowserListInputSchema>>>\n\nexport const BrowserCaptureFanoutInputSchema = {\n session_id: z.string().describe('The session id returned by browser_open or browser_list_sessions. The session must be on chatgpt.com or claude.ai and logged in through a saved hosted profile. Use only a returned session_id; do not construct one yourself.'),\n prompt: z.string().optional().describe('Optional prompt to type into the chat composer and submit before capturing. Omit to passively capture the fan-out of a prompt the user just ran in the visible browser. The prompt must trigger web search for there to be a fan-out.'),\n wait_ms: z.number().int().min(0).max(180000).optional().describe('How long to wait for the answer stream to finish before parsing. Defaults to 90000 when a prompt is sent, 8000 for passive capture. Capture ends as soon as the answer stream finishes.'),\n first_party_domain: z.string().optional().describe('The brand/site being researched, for example example.com. Sources on this domain are tagged First-party/vendor. Set this when the prompt is about a specific business.'),\n reset: z.boolean().default(false).describe('Clear any previously buffered stream for this page before capturing. Use when re-running to avoid mixing turns.'),\n export: z.boolean().default(false).describe('When true, write JSON, CSV, TSV exports (queries, citations, all sources, browsed-only sources, snippets, domains) and a self-contained HTML report to MCP_SCRAPER_OUTPUT_DIR/fanout, returning paths relative to MCP_SCRAPER_OUTPUT_DIR.'),\n}\nexport type BrowserCaptureFanoutInput = z.infer<ReturnType<typeof z.object<typeof BrowserCaptureFanoutInputSchema>>>\n\nconst FanoutSourceOutput = z.object({\n url: z.string(),\n domain: z.string(),\n title: z.string(),\n cited: z.boolean(),\n timesCited: z.number().int().min(0),\n snippet: z.string(),\n round: z.number().int().nullable(),\n siteType: z.string().describe('URL category: First-party/vendor, News/media, Reddit, Social/video, Encyclopedia, Review site, Docs, or Blog.'),\n})\n\nexport const BrowserCaptureFanoutOutputSchema = {\n ...BrowserBaseOutput,\n tool: z.literal('query_fanout_workflow'),\n platform: z.enum(['ChatGPT', 'Claude']).describe('Which AI-search surface the fan-out was captured from.'),\n captured_at: z.string(),\n prompt: z.string().describe('The user prompt that triggered the captured fan-out, when recoverable.'),\n meta: z.object({\n model: z.string(),\n finishType: z.string(),\n title: z.string(),\n rounds: z.number().int().min(0),\n }),\n queries: z.array(z.string()).describe('Every web-search sub-query the model issued, in capture order. Classify these by funnel stage and type yourself from the text.'),\n browsed_urls: z.array(FanoutSourceOutput).describe('Every researched URL (cited and browsed-only), cited first.'),\n cited_urls: z.array(FanoutSourceOutput).describe('The subset of researched URLs actually cited in the final answer.'),\n browsed_only: z.array(FanoutSourceOutput).describe('Researched URLs the model pulled but did not cite.'),\n snippets: z.array(z.object({ url: z.string(), domain: z.string(), title: z.string(), text: z.string() })),\n counts: z.object({\n subQueries: z.number().int().min(0),\n browsed: z.number().int().min(0),\n cited: z.number().int().min(0),\n browsedOnly: z.number().int().min(0),\n }),\n aggregates: z.object({\n topSites: z.array(z.object({ domain: z.string(), count: z.number().int(), cited: z.boolean(), timesCited: z.number().int(), siteType: z.string() })),\n citationOrder: z.array(z.object({ rank: z.number().int(), domain: z.string(), url: z.string(), timesCited: z.number().int() })),\n byCategory: z.record(z.number().int()),\n }).describe('Objective aggregates: top sourced sites by frequency, citation order, and URL-category counts.'),\n first_party_domain: z.string().nullable(),\n exports: z.object({\n relativeTo: z.string(),\n dir: z.string(),\n json: z.string(),\n queriesCsv: z.string(),\n queriesTsv: z.string(),\n citationsCsv: z.string(),\n sourcesCsv: z.string(),\n browsedOnlyCsv: z.string(),\n snippetsCsv: z.string(),\n domainsCsv: z.string(),\n report: z.string(),\n }).nullable().describe('Relative export paths when export=true, otherwise null. Paths are relative to MCP_SCRAPER_OUTPUT_DIR, or ~/Downloads/mcp-scraper when that env var is not set.'),\n debug: z.object({\n interceptorReady: z.boolean(),\n rawBytes: z.number().int().min(0),\n unmappedKeys: z.array(z.string()),\n note: z.string(),\n }).optional(),\n}\n\nexport const BrowserOpenOutputSchema = {\n ok: z.boolean(),\n tool: z.literal('browser_open'),\n session_id: z.string().describe('Session id returned by browser_open. Use only this exact value in later browser_* calls; do not construct one yourself.'),\n watch_url: z.string().describe('Human watch/takeover URL for this browser session on mcpscraper.dev.'),\n live_view_url: NullableString.describe('Deprecated; always null. Open watch_url to view the live session.'),\n url: NullableString.describe('Initial URL requested by the caller, when provided.'),\n hint: z.string(),\n raw: BrowserRawObject.optional(),\n}\n\nconst BrowserProfileLogin = z.object({\n connection_id: NullableString.describe('Auth connection id for this login.'),\n domain: z.string().describe('Site this login is for, e.g. chatgpt.com.'),\n status: z.string().describe('Auth status, e.g. NEEDS_AUTH or AUTHENTICATED.'),\n account_email: NullableString.describe('Account email recorded for this login, when known.'),\n note: NullableString.describe('Free-text note describing this login.'),\n watch_url: NullableString.describe('mcpscraper.dev sign-in link when this login still needs the user to authenticate.'),\n last_connected_at: NullableString.describe('When this login was last saved or refreshed.'),\n})\n\nexport const BrowserProfileConnectOutputSchema = {\n ok: z.boolean(),\n tool: z.literal('browser_profile_connect'),\n session_id: NullableString,\n auth_connection_id: z.string(),\n watch_url: z.string().describe('mcpscraper.dev sign-in link to give the user so they can complete this login.'),\n live_view_url: NullableString.describe('Deprecated; always null. Open watch_url to view the sign-in.'),\n profile: z.string().describe('Profile this login was added to. Reuse it to stack more logins or to open a session.'),\n domain: z.string(),\n setup_url: z.string(),\n account_email: NullableString,\n note: NullableString,\n status: z.string(),\n flow_status: NullableString,\n flow_step: NullableString,\n flow_expires_at: NullableString,\n post_login_url: NullableString,\n connected_logins: z.array(BrowserProfileLogin).describe('Every login currently saved in this profile, so you can see what else is connected.'),\n next_steps: z.array(z.string()),\n raw: BrowserRawObject.optional(),\n}\n\nexport const BrowserProfileListOutputSchema = {\n ok: z.boolean(),\n tool: z.literal('browser_profile_list'),\n session_id: z.null(),\n profile: z.string().describe('Profile these logins belong to.'),\n connections: z.array(BrowserProfileLogin).describe('All site logins saved in this profile, each with its current auth status and note.'),\n count: z.number().int().min(0),\n}\n\nexport const BrowserScreenshotOutputSchema = {\n ...BrowserBaseOutput,\n tool: z.literal('browser_screenshot'),\n url: NullableString,\n title: NullableString,\n text: z.string(),\n elements: z.array(BrowserElementOutput),\n screenshot: z.object({\n mime_type: z.string(),\n inline: z.boolean(),\n }).nullable(),\n}\n\nexport const BrowserReadOutputSchema = {\n ...BrowserBaseOutput,\n tool: z.literal('browser_read'),\n url: NullableString,\n title: NullableString,\n text: z.string(),\n elements: z.array(BrowserElementOutput),\n raw: BrowserRawObject.optional(),\n}\n\nexport const BrowserLocateOutputSchema = {\n ...BrowserBaseOutput,\n tool: z.literal('browser_locate'),\n url: NullableString,\n title: NullableString,\n viewport: BrowserRawObject.nullable(),\n replay: BrowserRawObject.nullable(),\n targets: z.array(BrowserRawObject),\n raw: BrowserRawObject.optional(),\n}\n\nexport const BrowserActionOutputSchema = {\n ...BrowserBaseOutput,\n result: BrowserRawObject.describe('Provider action result. Check ok and follow with browser_screenshot/browser_read when page state matters.'),\n nextRecommendedTool: z.string().nullable(),\n}\n\nexport const BrowserReplayStartOutputSchema = {\n ...BrowserReplayBaseOutput,\n tool: z.literal('browser_replay_start'),\n view_url: NullableString,\n download_url: NullableString,\n raw: BrowserRawObject.optional(),\n}\n\nexport const BrowserReplayStopOutputSchema = {\n ...BrowserReplayBaseOutput,\n tool: z.literal('browser_replay_stop'),\n view_url: NullableString,\n download_url: NullableString,\n raw: BrowserRawObject.optional(),\n}\n\nexport const BrowserListReplaysOutputSchema = {\n ...BrowserBaseOutput,\n tool: z.literal('browser_list_replays'),\n replays: z.array(BrowserRawObject),\n count: z.number().int().min(0),\n}\n\nexport const BrowserReplayDownloadOutputSchema = {\n ...BrowserReplayBaseOutput,\n tool: z.literal('browser_replay_download'),\n file_path: NullableString,\n bytes: z.number().int().min(0).nullable(),\n mime_type: NullableString,\n download_url: NullableString,\n}\n\nexport const BrowserReplayMarkOutputSchema = {\n ...BrowserReplayBaseOutput,\n tool: z.literal('browser_replay_mark'),\n annotation: BrowserRawObject,\n source_width: z.number().nullable(),\n source_height: z.number().nullable(),\n target: BrowserRawObject.nullable(),\n hint: z.string(),\n}\n\nexport const BrowserReplayAnnotateOutputSchema = {\n ...BrowserReplayBaseOutput,\n tool: z.literal('browser_replay_annotate'),\n source_file_path: NullableString,\n annotated_file_path: NullableString,\n bytes: z.number().int().min(0).nullable(),\n width: z.number().int().min(0).nullable(),\n height: z.number().int().min(0).nullable(),\n annotation_count: z.number().int().min(0).nullable(),\n mime_type: NullableString,\n}\n\nexport const BrowserCloseOutputSchema = {\n ...BrowserBaseOutput,\n tool: z.literal('browser_close'),\n closed: z.boolean(),\n raw: BrowserRawObject.optional(),\n}\n\nexport const BrowserListSessionsOutputSchema = {\n ok: z.boolean(),\n tool: z.literal('browser_list_sessions'),\n session_id: z.null(),\n sessions: z.array(BrowserRawObject),\n count: z.number().int().min(0),\n}\n","import { execFile } from 'node:child_process'\nimport { mkdtemp, rm, stat, writeFile } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { promisify } from 'node:util'\n\nconst execFileAsync = promisify(execFile)\n\nexport type ReplayAnnotationType = 'box' | 'circle' | 'underline' | 'arrow' | 'label'\n\nexport interface ReplayAnnotation {\n type?: ReplayAnnotationType\n start_seconds?: number\n end_seconds?: number\n left?: number\n top?: number\n width?: number\n height?: number\n x?: number\n y?: number\n from_x?: number\n from_y?: number\n to_x?: number\n to_y?: number\n label?: string\n color?: string\n thickness?: number\n}\n\nexport interface AnnotateReplayOptions {\n annotations: ReplayAnnotation[]\n sourceWidth?: number\n sourceHeight?: number\n sourceLeftOffset?: number\n sourceTopOffset?: number\n}\n\ninterface Size {\n width: number\n height: number\n}\n\ninterface Rect {\n left: number\n top: number\n width: number\n height: number\n}\n\ninterface CoordinateTransform {\n scaleX: number\n scaleY: number\n offsetX: number\n offsetY: number\n}\n\nexport interface AnnotatedReplayResult {\n filePath: string\n bytes: number\n width: number\n height: number\n annotationCount: number\n}\n\nfunction finiteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value)\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value))\n}\n\nfunction formatAssTime(seconds: number): string {\n const safe = Math.max(0, seconds)\n const hours = Math.floor(safe / 3600)\n const minutes = Math.floor((safe % 3600) / 60)\n const wholeSeconds = Math.floor(safe % 60)\n const centiseconds = Math.floor((safe - Math.floor(safe)) * 100)\n return `${hours}:${String(minutes).padStart(2, '0')}:${String(wholeSeconds).padStart(2, '0')}.${String(centiseconds).padStart(2, '0')}`\n}\n\nfunction cssHexToAssColor(color?: string): string {\n const normalized = color?.trim().match(/^#?([0-9a-fA-F]{6})$/)?.[1] ?? 'ff3b30'\n const red = normalized.slice(0, 2)\n const green = normalized.slice(2, 4)\n const blue = normalized.slice(4, 6)\n return `&H${blue}${green}${red}&`\n}\n\nfunction escapeAssText(value: string): string {\n return value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\\{/g, '\\\\{')\n .replace(/\\}/g, '\\\\}')\n .replace(/\\r?\\n/g, '\\\\N')\n}\n\nfunction resolveCoordinateTransform(video: Size, source: Size, options: AnnotateReplayOptions): CoordinateTransform {\n const explicitOffsetX = finiteNumber(options.sourceLeftOffset) ? options.sourceLeftOffset : null\n const explicitOffsetY = finiteNumber(options.sourceTopOffset) ? options.sourceTopOffset : null\n const inferredTopOffset =\n explicitOffsetY == null &&\n Math.round(source.width) === Math.round(video.width) &&\n source.height < video.height &&\n video.height - source.height <= 220\n ? video.height - source.height\n : 0\n const offsetX = explicitOffsetX ?? 0\n const offsetY = explicitOffsetY ?? inferredTopOffset\n return {\n scaleX: (video.width - offsetX) / source.width,\n scaleY: (video.height - offsetY) / source.height,\n offsetX,\n offsetY,\n }\n}\n\nfunction transformPoint(x: number, y: number, transform: CoordinateTransform): { x: number; y: number } {\n return {\n x: x * transform.scaleX + transform.offsetX,\n y: y * transform.scaleY + transform.offsetY,\n }\n}\n\nfunction scaleRect(annotation: ReplayAnnotation, transform: CoordinateTransform): Rect {\n if (\n finiteNumber(annotation.left) &&\n finiteNumber(annotation.top) &&\n finiteNumber(annotation.width) &&\n finiteNumber(annotation.height)\n ) {\n const origin = transformPoint(annotation.left, annotation.top, transform)\n return {\n left: origin.x,\n top: origin.y,\n width: annotation.width * transform.scaleX,\n height: annotation.height * transform.scaleY,\n }\n }\n if (finiteNumber(annotation.x) && finiteNumber(annotation.y)) {\n const radius = finiteNumber(annotation.width) ? annotation.width / 2 : 28\n const point = transformPoint(annotation.x, annotation.y, transform)\n return {\n left: point.x - radius * transform.scaleX,\n top: point.y - radius * transform.scaleY,\n width: radius * 2 * transform.scaleX,\n height: radius * 2 * transform.scaleY,\n }\n }\n throw new Error('annotation needs either left/top/width/height or x/y')\n}\n\nfunction rectPath(rect: Rect): string {\n const x1 = Math.round(rect.left)\n const y1 = Math.round(rect.top)\n const x2 = Math.round(rect.left + rect.width)\n const y2 = Math.round(rect.top + rect.height)\n return `m ${x1} ${y1} l ${x2} ${y1} l ${x2} ${y2} l ${x1} ${y2} l ${x1} ${y1}`\n}\n\nfunction ellipsePath(rect: Rect): string {\n const cx = rect.left + rect.width / 2\n const cy = rect.top + rect.height / 2\n const rx = Math.max(4, rect.width / 2)\n const ry = Math.max(4, rect.height / 2)\n const points: string[] = []\n for (let i = 0; i <= 32; i += 1) {\n const t = (Math.PI * 2 * i) / 32\n const x = Math.round(cx + Math.cos(t) * rx)\n const y = Math.round(cy + Math.sin(t) * ry)\n points.push(`${i === 0 ? 'm' : 'l'} ${x} ${y}`)\n }\n return points.join(' ')\n}\n\nfunction filledRectPath(left: number, top: number, width: number, height: number): string {\n return rectPath({ left, top, width, height })\n}\n\nfunction arrowPath(fromX: number, fromY: number, toX: number, toY: number, thickness: number): string {\n const dx = toX - fromX\n const dy = toY - fromY\n const length = Math.max(1, Math.hypot(dx, dy))\n const ux = dx / length\n const uy = dy / length\n const px = -uy\n const py = ux\n const half = thickness / 2\n const head = Math.max(14, thickness * 4)\n const baseX = toX - ux * head\n const baseY = toY - uy * head\n const p1x = Math.round(fromX + px * half)\n const p1y = Math.round(fromY + py * half)\n const p2x = Math.round(baseX + px * half)\n const p2y = Math.round(baseY + py * half)\n const p3x = Math.round(baseX + px * head * 0.55)\n const p3y = Math.round(baseY + py * head * 0.55)\n const p4x = Math.round(toX)\n const p4y = Math.round(toY)\n const p5x = Math.round(baseX - px * head * 0.55)\n const p5y = Math.round(baseY - py * head * 0.55)\n const p6x = Math.round(baseX - px * half)\n const p6y = Math.round(baseY - py * half)\n const p7x = Math.round(fromX - px * half)\n const p7y = Math.round(fromY - py * half)\n return `m ${p1x} ${p1y} l ${p2x} ${p2y} l ${p3x} ${p3y} l ${p4x} ${p4y} l ${p5x} ${p5y} l ${p6x} ${p6y} l ${p7x} ${p7y} l ${p1x} ${p1y}`\n}\n\nfunction eventLine(start: number, end: number, body: string): string {\n return `Dialogue: 0,${formatAssTime(start)},${formatAssTime(end)},Default,,0,0,0,,${body}`\n}\n\nfunction labelLine(start: number, end: number, x: number, y: number, label: string): string {\n const safeX = Math.round(x)\n const safeY = Math.round(y)\n return eventLine(\n start,\n end,\n `{\\\\an7\\\\pos(${safeX},${safeY})\\\\fs30\\\\bord4\\\\shad0\\\\c&HFFFFFF&\\\\3c&H000000&}${escapeAssText(label)}`,\n )\n}\n\nfunction shapeLine(start: number, end: number, path: string, color: string, thickness: number, filled = false): string {\n const fillAlpha = filled ? '&H00&' : '&HFF&'\n const border = filled ? 0 : thickness\n return eventLine(\n start,\n end,\n `{\\\\an7\\\\pos(0,0)\\\\p1\\\\bord${border}\\\\shad0\\\\1a${fillAlpha}\\\\1c${color}\\\\3c${color}}${path}`,\n )\n}\n\nexport function buildAssSubtitle(options: AnnotateReplayOptions, video: Size): string {\n const source = {\n width: options.sourceWidth && options.sourceWidth > 0 ? options.sourceWidth : video.width,\n height: options.sourceHeight && options.sourceHeight > 0 ? options.sourceHeight : video.height,\n }\n const transform = resolveCoordinateTransform(video, source, options)\n const lines: string[] = []\n for (const annotation of options.annotations) {\n const start = Math.max(0, annotation.start_seconds ?? 0)\n const end = annotation.end_seconds && annotation.end_seconds > start ? annotation.end_seconds : start + 2\n const type = annotation.type ?? 'box'\n const color = cssHexToAssColor(annotation.color)\n const thickness = Math.round(clamp(annotation.thickness ?? 5, 2, 24))\n if (type === 'label') {\n if (!annotation.label) throw new Error('label annotation needs label')\n const rect = scaleRect(annotation, transform)\n lines.push(labelLine(start, end, rect.left, Math.max(8, rect.top), annotation.label))\n continue\n }\n if (type === 'arrow') {\n const rect = finiteNumber(annotation.to_x) && finiteNumber(annotation.to_y)\n ? null\n : scaleRect(annotation, transform)\n const toPoint = finiteNumber(annotation.to_x) && finiteNumber(annotation.to_y)\n ? transformPoint(annotation.to_x, annotation.to_y, transform)\n : null\n const toX = toPoint ? toPoint.x : rect!.left + rect!.width / 2\n const toY = toPoint ? toPoint.y : rect!.top + rect!.height / 2\n const fromPoint = finiteNumber(annotation.from_x) && finiteNumber(annotation.from_y)\n ? transformPoint(annotation.from_x, annotation.from_y, transform)\n : null\n const fromX = fromPoint ? fromPoint.x : clamp(toX - 120, 12, video.width - 12)\n const fromY = fromPoint ? fromPoint.y : clamp(toY - 90, 12, video.height - 12)\n lines.push(shapeLine(start, end, arrowPath(fromX, fromY, toX, toY, thickness), color, thickness, true))\n if (annotation.label) lines.push(labelLine(start, end, fromX + 8, Math.max(96, fromY - 36), annotation.label))\n continue\n }\n const rect = scaleRect(annotation, transform)\n if (type === 'underline') {\n const underlineTop = rect.top + rect.height + thickness\n lines.push(shapeLine(start, end, filledRectPath(rect.left, underlineTop, rect.width, thickness), color, 0, true))\n } else if (type === 'circle') {\n lines.push(shapeLine(start, end, ellipsePath(rect), color, thickness))\n } else {\n lines.push(shapeLine(start, end, rectPath(rect), color, thickness))\n }\n if (annotation.label) lines.push(labelLine(start, end, rect.left, Math.max(8, rect.top - 38), annotation.label))\n }\n\n return [\n '[Script Info]',\n 'ScriptType: v4.00+',\n `PlayResX: ${Math.round(video.width)}`,\n `PlayResY: ${Math.round(video.height)}`,\n 'ScaledBorderAndShadow: yes',\n '',\n '[V4+ Styles]',\n 'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding',\n 'Style: Default,Arial,30,&H00FFFFFF,&H000000FF,&H00000000,&H90000000,0,0,0,0,100,100,0,0,1,2,0,7,0,0,0,1',\n '',\n '[Events]',\n 'Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text',\n ...lines,\n '',\n ].join('\\n')\n}\n\nasync function videoSize(inputFilePath: string): Promise<Size> {\n const { stdout } = await execFileAsync('ffprobe', [\n '-v',\n 'error',\n '-select_streams',\n 'v:0',\n '-show_entries',\n 'stream=width,height',\n '-of',\n 'json',\n inputFilePath,\n ], { maxBuffer: 1024 * 1024 })\n const parsed = JSON.parse(stdout) as { streams?: Array<{ width?: number; height?: number }> }\n const stream = parsed.streams?.[0]\n if (!stream?.width || !stream.height) throw new Error('could not read replay video dimensions')\n return { width: stream.width, height: stream.height }\n}\n\nfunction ffmpegFilterPath(path: string): string {\n return path.replace(/\\\\/g, '\\\\\\\\').replace(/:/g, '\\\\:')\n}\n\nexport async function annotateReplayVideo(\n inputFilePath: string,\n outputFilePath: string,\n options: AnnotateReplayOptions,\n): Promise<AnnotatedReplayResult> {\n if (!options.annotations.length) throw new Error('annotations must include at least one item')\n const size = await videoSize(inputFilePath)\n const tmp = await mkdtemp(join(tmpdir(), 'mcp-scraper-ass-'))\n const assPath = join(tmp, 'annotations.ass')\n try {\n await writeFile(assPath, buildAssSubtitle(options, size), 'utf8')\n await execFileAsync('ffmpeg', [\n '-y',\n '-i',\n inputFilePath,\n '-vf',\n `ass=${ffmpegFilterPath(assPath)}`,\n '-c:v',\n 'libx264',\n '-pix_fmt',\n 'yuv420p',\n '-movflags',\n '+faststart',\n '-c:a',\n 'copy',\n outputFilePath,\n ], { maxBuffer: 1024 * 1024 * 20 })\n const out = await stat(outputFilePath)\n return {\n filePath: outputFilePath,\n bytes: out.size,\n width: size.width,\n height: size.height,\n annotationCount: options.annotations.length,\n }\n } finally {\n await rm(tmp, { recursive: true, force: true })\n }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B,KAAK,KAAK,QAAQ,IAAI,cAAc,KAAK,KAAK;AAChG,IAAM,iBAAiB,QAAQ,IAAI,2BAA2B,KAAK,KAAK;AACxE,IAAM,SAAS,IAAIC,WAAU,EAAE,MAAM,eAAe,SAAS,gBAAgB,GAAG,EAAE,cAAc,oBAAoB,CAAC;AAErH,6BAA6B,QAAQ,IAAI,oBAAoB,SAAS,MAAM,CAAC;AAC7E,6BAA6B,QAAQ,EAAE,SAAS,QAAQ,eAAe,CAAC;AAExE,IAAM,YAAY,IAAI,qBAAqB;AAE3C,eAAe,OAAO;AACpB,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,SAAO;AAClB,UAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["homedir","join","McpServer","join","rect","join","finiteNumber","server","baseUrl","join","finiteNumber","exports","join","homedir","McpServer"]}
|
package/dist/bin/paa-harvest.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
harvest
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-M2S27J6Z.js";
|
|
4
|
+
} from "../chunk-IGOEAKC7.js";
|
|
6
5
|
import {
|
|
7
6
|
browserServiceApiKey
|
|
8
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ZAP7MYVO.js";
|
|
9
8
|
import "../chunk-LFATOGDF.js";
|
|
10
9
|
|
|
11
10
|
// src/cli.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli.ts","../../bin/paa-harvest.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { browserServiceApiKey } from './lib/browser-service-env.js'\nimport { harvest } from './harvest.js'\n\nconst program = new Command()\n\nprogram\n .name('paa-harvest')\n .description('Recursively extract Google People Also Ask questions')\n .requiredOption('-q, --query <query>', 'Seed query')\n .option('-l, --location <location>', 'Location name (e.g. \"austin\" or \"Austin,Texas,United States\")')\n .option('--gl <gl>', 'Google country code', 'us')\n .option('--hl <hl>', 'Google language code', 'en')\n .option('-d, --depth <depth>', 'BFS depth (1-30)', '3')\n .option('-m, --max-questions <n>', 'Max questions to harvest', '100')\n .option('-o, --output <dir>', 'Output directory', './paa-output')\n .option('-f, --format <format>', 'Output format: json, csv, or both', 'both')\n .option('--headless', 'Run browser in headless mode', false)\n .option('--profile <dir>', 'Persistent browser profile directory')\n .option('--proxy <url>', 'Proxy server URL')\n .option('--kernel-api-key <key>', 'Browser service API key (or set BROWSER_SERVICE_API_KEY env var)')\n .action(async (opts) => {\n try {\n const result = await harvest({\n query: opts.query,\n location: opts.location,\n gl: opts.gl,\n hl: opts.hl,\n depth: parseInt(opts.depth, 10),\n maxQuestions: parseInt(opts.maxQuestions, 10),\n outputDir: opts.output,\n format: opts.format,\n headless: opts.headless,\n profileDir: opts.profile,\n proxy: opts.proxy,\n kernelApiKey: opts.kernelApiKey ?? browserServiceApiKey(),\n })\n console.log(JSON.stringify({ totalQuestions: result.totalQuestions, outputDir: result.stats.seed }))\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err))\n process.exit(1)\n }\n })\n\nexport async function runCli(): Promise<void> {\n await program.parseAsync()\n}\n","#!/usr/bin/env node\nimport { runCli } from '../src/cli.js'\nrunCli()\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/cli.ts","../../bin/paa-harvest.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { browserServiceApiKey } from './lib/browser-service-env.js'\nimport { harvest } from './harvest.js'\n\nconst program = new Command()\n\nprogram\n .name('paa-harvest')\n .description('Recursively extract Google People Also Ask questions')\n .requiredOption('-q, --query <query>', 'Seed query')\n .option('-l, --location <location>', 'Location name (e.g. \"austin\" or \"Austin,Texas,United States\")')\n .option('--gl <gl>', 'Google country code', 'us')\n .option('--hl <hl>', 'Google language code', 'en')\n .option('-d, --depth <depth>', 'BFS depth (1-30)', '3')\n .option('-m, --max-questions <n>', 'Max questions to harvest', '100')\n .option('-o, --output <dir>', 'Output directory', './paa-output')\n .option('-f, --format <format>', 'Output format: json, csv, or both', 'both')\n .option('--headless', 'Run browser in headless mode', false)\n .option('--profile <dir>', 'Persistent browser profile directory')\n .option('--proxy <url>', 'Proxy server URL')\n .option('--kernel-api-key <key>', 'Browser service API key (or set BROWSER_SERVICE_API_KEY env var)')\n .action(async (opts) => {\n try {\n const result = await harvest({\n query: opts.query,\n location: opts.location,\n gl: opts.gl,\n hl: opts.hl,\n depth: parseInt(opts.depth, 10),\n maxQuestions: parseInt(opts.maxQuestions, 10),\n outputDir: opts.output,\n format: opts.format,\n headless: opts.headless,\n profileDir: opts.profile,\n proxy: opts.proxy,\n kernelApiKey: opts.kernelApiKey ?? browserServiceApiKey(),\n })\n console.log(JSON.stringify({ totalQuestions: result.totalQuestions, outputDir: result.stats.seed }))\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err))\n process.exit(1)\n }\n })\n\nexport async function runCli(): Promise<void> {\n await program.parseAsync()\n}\n","#!/usr/bin/env node\nimport { runCli } from '../src/cli.js'\nrunCli()\n"],"mappings":";;;;;;;;;;AAAA,SAAS,eAAe;AAIxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,aAAa,EAClB,YAAY,sDAAsD,EAClE,eAAe,uBAAuB,YAAY,EAClD,OAAO,6BAA6B,+DAA+D,EACnG,OAAO,aAAa,uBAAuB,IAAI,EAC/C,OAAO,aAAa,wBAAwB,IAAI,EAChD,OAAO,uBAAuB,oBAAoB,GAAG,EACrD,OAAO,2BAA2B,4BAA4B,KAAK,EACnE,OAAO,sBAAsB,oBAAoB,cAAc,EAC/D,OAAO,yBAAyB,qCAAqC,MAAM,EAC3E,OAAO,cAAc,gCAAgC,KAAK,EAC1D,OAAO,mBAAmB,sCAAsC,EAChE,OAAO,iBAAiB,kBAAkB,EAC1C,OAAO,0BAA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