mcp-scraper 0.3.9 → 0.3.11

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.
Files changed (36) hide show
  1. package/README.md +6 -4
  2. package/dist/bin/api-server.cjs +138 -19
  3. package/dist/bin/api-server.cjs.map +1 -1
  4. package/dist/bin/api-server.js +1 -1
  5. package/dist/bin/browser-agent-stdio-server.cjs +104 -28
  6. package/dist/bin/browser-agent-stdio-server.cjs.map +1 -1
  7. package/dist/bin/browser-agent-stdio-server.js +2 -2
  8. package/dist/bin/mcp-scraper-cli.cjs +1 -1
  9. package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
  10. package/dist/bin/mcp-scraper-cli.js +1 -1
  11. package/dist/bin/mcp-scraper-combined-stdio-server.cjs +110 -34
  12. package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +1 -1
  13. package/dist/bin/mcp-scraper-combined-stdio-server.js +4 -4
  14. package/dist/bin/mcp-scraper-install.cjs +7 -7
  15. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  16. package/dist/bin/mcp-scraper-install.js +2 -2
  17. package/dist/bin/mcp-stdio-server.cjs +1 -1
  18. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  19. package/dist/bin/mcp-stdio-server.js +2 -2
  20. package/dist/{chunk-ELI6NDEG.js → chunk-KPXMPAJ3.js} +7 -7
  21. package/dist/chunk-KPXMPAJ3.js.map +1 -0
  22. package/dist/{chunk-BRUVQRJK.js → chunk-L27GJQV7.js} +105 -29
  23. package/dist/chunk-L27GJQV7.js.map +1 -0
  24. package/dist/chunk-RRE7WVHQ.js +7 -0
  25. package/dist/chunk-RRE7WVHQ.js.map +1 -0
  26. package/dist/{chunk-KDKQ5Y7V.js → chunk-VMH7SRWY.js} +2 -2
  27. package/dist/{server-ZSHE4R5Z.js → server-3SA5Q4OF.js} +140 -21
  28. package/dist/{server-ZSHE4R5Z.js.map → server-3SA5Q4OF.js.map} +1 -1
  29. package/docs/mcp-tool-craft-lint.generated.md +3 -2
  30. package/docs/mcp-tool-manifest.generated.json +43 -13
  31. package/package.json +1 -1
  32. package/dist/chunk-7VNTN4Q7.js +0 -7
  33. package/dist/chunk-7VNTN4Q7.js.map +0 -1
  34. package/dist/chunk-BRUVQRJK.js.map +0 -1
  35. package/dist/chunk-ELI6NDEG.js.map +0 -1
  36. /package/dist/{chunk-KDKQ5Y7V.js.map → chunk-VMH7SRWY.js.map} +0 -0
package/README.md CHANGED
@@ -119,7 +119,7 @@ For customer AI visibility setup, use the hosted profile connection flow. Open t
119
119
 
120
120
  Browser-agent hosted sessions are direct/no-proxy by default. They do not inherit the configured SERP/Maps proxy. Use proxies for SERP/Maps tools when those tools need location or anti-bot handling, not for the interactive login browser.
121
121
 
122
- `BROWSER_AGENT_PROFILE_NAME` sets the default saved hosted browser profile for future sessions. For first-time setup, use `browser_profile_onboard`, open the returned `watch_url`, complete login in the hosted browser, then call `browser_close` to persist cookies and storage into the saved profile.
122
+ `BROWSER_AGENT_PROFILE_NAME` sets the default saved hosted browser profile for future sessions. For first-time setup, use `browser_profile_onboard`, open the returned `watch_url`, complete login, then call `browser_profile_status` until the connection is authenticated.
123
123
 
124
124
  Inside MCP clients, use `browser_profile_onboard` for customer setup and reconnects. The customer signs in through the hosted `watch_url` so they control the login session directly.
125
125
 
@@ -202,7 +202,8 @@ env = { MCP_SCRAPER_API_KEY = "sk_live_your_key" }
202
202
  ### Browser-agent tools
203
203
 
204
204
  - `browser_open` — open a direct/no-proxy hosted browser session. Pass a saved profile name to load an authenticated session. Returns a human `watch_url`.
205
- - `browser_profile_onboard` — create or load a saved hosted browser profile and open a direct/no-proxy setup browser at Google with profile saving enabled. The user clicks Sign in through the `watch_url`, then `browser_close` persists cookies and storage into the saved profile. Use this again whenever the profile disconnects.
205
+ - `browser_profile_onboard` — create or load a saved hosted browser profile auth connection and return a user takeover `watch_url`. The user signs in through that URL, then `browser_profile_status` verifies the profile is authenticated. Use this again whenever the profile disconnects.
206
+ - `browser_profile_status` — check whether a hosted browser profile auth connection is authenticated before launching it with `browser_open`.
206
207
  - `browser_screenshot` — capture a screenshot plus visible text and clickable element center coordinates and DOM bounds.
207
208
  - `browser_read` — read the current page text and elements with center coordinates and DOM bounds, without an image.
208
209
  - `browser_locate` — locate exact visible DOM elements or text ranges and return screenshot-pixel bounds.
@@ -217,6 +218,7 @@ env = { MCP_SCRAPER_API_KEY = "sk_live_your_key" }
217
218
  - `browser_replay_download` — download and save the replay MP4 under `MCP_SCRAPER_OUTPUT_DIR/browser-replays`.
218
219
  - `browser_replay_mark` — while recording, locate a DOM target and return a replay-timed annotation object.
219
220
  - `browser_replay_annotate` — download a replay MP4, render timed boxes, circles, underlines, arrows, and labels using annotation objects from `browser_replay_mark` or exact bounds from `browser_locate`, and save a new annotated MP4 under `MCP_SCRAPER_OUTPUT_DIR/browser-replays`.
221
+ - `browser_capture_fanout` — capture ChatGPT/Claude AI-search fan-out from an open logged-in hosted session. Use `export=true` for durable artifacts. It writes full `fanout.json`, query/source/citation/domain/snippet CSVs, TSV, and `report.html` under `MCP_SCRAPER_OUTPUT_DIR/fanout`, returning paths relative to `MCP_SCRAPER_OUTPUT_DIR` so users can share portable paths.
220
222
  - `browser_close`
221
223
  - `browser_list_sessions`
222
224
 
@@ -230,7 +232,7 @@ The MCPB bundle and `mcp-scraper-combined` expose both sections through one MCP
230
232
 
231
233
  All MCP tools expose output schemas and return `structuredContent` with the IDs, URLs, CSV paths, transcripts, browser session handles, replay paths, artifacts, recipe fields, or blueprint fields needed by the next step. Browser Agent tools keep a JSON text block for older clients, but structured data is the primary contract. All tools carry MCP annotations; file-writing tools such as replay downloads and annotations state their filesystem side effects.
232
234
 
233
- The canonical tool inventory is generated at `docs/mcp-tool-manifest.generated.json`. The split `mcp-scraper` stdio server exposes 24 web-intelligence/workflow tools. The split `browser-agent` stdio server exposes 19 browser tools. The combined stdio server exposes 43 tools. The hosted MCP endpoint at `https://mcpscraper.dev/mcp` exposes the 24 web-intelligence/workflow tools plus `capture_serp_snapshot` and `capture_serp_page_snapshots` (26 total). Across all public surfaces there are 45 unique tool names.
235
+ The canonical tool inventory is generated at `docs/mcp-tool-manifest.generated.json`. The split `mcp-scraper` stdio server exposes 24 web-intelligence/workflow tools. The split `browser-agent` stdio server exposes 20 browser tools. The combined stdio server exposes 44 tools. The hosted MCP endpoint at `https://mcpscraper.dev/mcp` exposes the 24 web-intelligence/workflow tools plus `capture_serp_snapshot` and `capture_serp_page_snapshots` (26 total). Across all public surfaces there are 46 unique tool names.
234
236
 
235
237
  ## Resources
236
238
 
@@ -246,7 +248,7 @@ The `mcp-scraper` and `mcp-scraper-combined` NPX stdio servers also expose saved
246
248
  - `BROWSER_AGENT_PROFILE_NAME` is optional and sets the default saved hosted browser profile for `browser-agent` and `mcp-scraper-combined` stdio sessions. Aliases: `BROWSER_SERVICE_PROFILE_NAME`, `KERNEL_BROWSER_PROFILE_NAME`, `KERNEL_PROFILE_NAME`.
247
249
  - `BROWSER_AGENT_PROFILE_SAVE_CHANGES=true` is optional hosted setup behavior. It persists cookies and storage back to the named profile when `browser_close` deletes the hosted browser session. Aliases: `BROWSER_SERVICE_PROFILE_SAVE_CHANGES`, `KERNEL_BROWSER_PROFILE_SAVE_CHANGES`, `KERNEL_PROFILE_SAVE_CHANGES`.
248
250
 
249
- Every web intelligence tool call made through `mcp-scraper` or `mcp-scraper-combined` saves a full Markdown report to disk by default and returns the file path in the MCP response. The hosted `/mcp` endpoint returns reports inline only and never writes files. Browser replay downloads are saved by `browser_replay_download` under `MCP_SCRAPER_OUTPUT_DIR/browser-replays`.
251
+ Every web intelligence tool call made through `mcp-scraper` or `mcp-scraper-combined` saves a full Markdown report to disk by default and returns the file path in the MCP response. The hosted `/mcp` endpoint returns reports inline only and never writes files. Browser replay downloads are saved by `browser_replay_download` under `MCP_SCRAPER_OUTPUT_DIR/browser-replays`. AI fan-out exports are saved by `browser_capture_fanout` with `export=true` under `MCP_SCRAPER_OUTPUT_DIR/fanout`, and return relative paths.
250
252
 
251
253
  ## Updating Existing Installs
252
254
 
@@ -21921,7 +21921,7 @@ var PACKAGE_VERSION;
21921
21921
  var init_version = __esm({
21922
21922
  "src/version.ts"() {
21923
21923
  "use strict";
21924
- PACKAGE_VERSION = "0.3.9";
21924
+ PACKAGE_VERSION = "0.3.11";
21925
21925
  }
21926
21926
  });
21927
21927
 
@@ -24432,7 +24432,9 @@ function writeTable(path6, rows, delimiter) {
24432
24432
  }
24433
24433
  function exportFanout(enriched) {
24434
24434
  const stamp = safe(enriched.capturedAt.replace(/[:.]/g, "-"));
24435
- const dir = (0, import_node_path11.join)(outputBaseDir3(), "fanout", `${stamp}-${safe(enriched.platform)}`);
24435
+ const outputDir = outputBaseDir3();
24436
+ const relativeDir = (0, import_node_path11.join)("fanout", `${stamp}-${safe(enriched.platform)}`);
24437
+ const dir = (0, import_node_path11.join)(outputDir, relativeDir);
24436
24438
  (0, import_node_fs8.mkdirSync)(dir, { recursive: true });
24437
24439
  const queryRows = enriched.queries.map((q, i) => ({ index: i + 1, query: q }));
24438
24440
  const citationRows = enriched.aggregates.citationOrder.map((c) => {
@@ -24440,25 +24442,32 @@ function exportFanout(enriched) {
24440
24442
  return { rank: c.rank, domain: c.domain, url: c.url, timesCited: c.timesCited, siteType: src?.siteType ?? "", title: src?.title ?? "" };
24441
24443
  });
24442
24444
  const sourceRows2 = enriched.browsedUrls.map((s) => ({ domain: s.domain, url: s.url, cited: s.cited, timesCited: s.timesCited, siteType: s.siteType, title: s.title, round: s.round ?? "" }));
24445
+ const browsedOnlyRows = enriched.browsedOnly.map((s) => ({ domain: s.domain, url: s.url, cited: s.cited, timesCited: s.timesCited, siteType: s.siteType, title: s.title, round: s.round ?? "" }));
24446
+ const snippetRows = enriched.snippets.map((s) => ({ domain: s.domain, url: s.url, title: s.title, text: s.text }));
24443
24447
  const domainRows = enriched.aggregates.topSites.map((d) => ({ domain: d.domain, count: d.count, cited: d.cited, timesCited: d.timesCited, siteType: d.siteType }));
24444
- const paths = {
24445
- dir,
24446
- json: (0, import_node_path11.join)(dir, "fanout.json"),
24447
- queriesCsv: (0, import_node_path11.join)(dir, "queries.csv"),
24448
- queriesTsv: (0, import_node_path11.join)(dir, "queries.tsv"),
24449
- citationsCsv: (0, import_node_path11.join)(dir, "citations.csv"),
24450
- sourcesCsv: (0, import_node_path11.join)(dir, "sources.csv"),
24451
- domainsCsv: (0, import_node_path11.join)(dir, "domains.csv"),
24452
- report: (0, import_node_path11.join)(dir, "report.html")
24448
+ const relativePaths = {
24449
+ relativeTo: "MCP_SCRAPER_OUTPUT_DIR or ~/Downloads/mcp-scraper",
24450
+ dir: relativeDir,
24451
+ json: (0, import_node_path11.join)(relativeDir, "fanout.json"),
24452
+ queriesCsv: (0, import_node_path11.join)(relativeDir, "queries.csv"),
24453
+ queriesTsv: (0, import_node_path11.join)(relativeDir, "queries.tsv"),
24454
+ citationsCsv: (0, import_node_path11.join)(relativeDir, "citations.csv"),
24455
+ sourcesCsv: (0, import_node_path11.join)(relativeDir, "sources.csv"),
24456
+ browsedOnlyCsv: (0, import_node_path11.join)(relativeDir, "browsed-only.csv"),
24457
+ snippetsCsv: (0, import_node_path11.join)(relativeDir, "snippets.csv"),
24458
+ domainsCsv: (0, import_node_path11.join)(relativeDir, "domains.csv"),
24459
+ report: (0, import_node_path11.join)(relativeDir, "report.html")
24453
24460
  };
24454
- (0, import_node_fs8.writeFileSync)(paths.json, JSON.stringify(enriched, null, 2));
24455
- writeTable(paths.queriesCsv, queryRows, ",");
24456
- writeTable(paths.queriesTsv, queryRows, " ");
24457
- writeTable(paths.citationsCsv, citationRows, ",");
24458
- writeTable(paths.sourcesCsv, sourceRows2, ",");
24459
- writeTable(paths.domainsCsv, domainRows, ",");
24460
- (0, import_node_fs8.writeFileSync)(paths.report, renderReportHtml(enriched));
24461
- return paths;
24461
+ (0, import_node_fs8.writeFileSync)((0, import_node_path11.join)(outputDir, relativePaths.json), JSON.stringify(enriched, null, 2));
24462
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.queriesCsv), queryRows, ",");
24463
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.queriesTsv), queryRows, " ");
24464
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.citationsCsv), citationRows, ",");
24465
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.sourcesCsv), sourceRows2, ",");
24466
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.browsedOnlyCsv), browsedOnlyRows, ",");
24467
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.snippetsCsv), snippetRows, ",");
24468
+ writeTable((0, import_node_path11.join)(outputDir, relativePaths.domainsCsv), domainRows, ",");
24469
+ (0, import_node_fs8.writeFileSync)((0, import_node_path11.join)(outputDir, relativePaths.report), renderReportHtml(enriched));
24470
+ return relativePaths;
24462
24471
  }
24463
24472
  function esc(s) {
24464
24473
  return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -24575,6 +24584,7 @@ async function runFanoutCapture(page, input) {
24575
24584
  const cap = new FanoutCdpCapture();
24576
24585
  await cap.attach(page);
24577
24586
  try {
24587
+ if (input.reset) cap.reset();
24578
24588
  const baseline = cap.answerStreamCount();
24579
24589
  if (input.prompt) await sendPrompt(page, input.prompt).catch(() => false);
24580
24590
  const waitMs = input.wait_ms ?? (input.prompt ? 9e4 : 8e3);
@@ -24639,10 +24649,68 @@ async function ensureProfile(k, name) {
24639
24649
  if (!isProfileConflict(err)) throw err;
24640
24650
  }
24641
24651
  }
24652
+ function profileConnectionMatches(connection, profileName, domain) {
24653
+ if (!connection || typeof connection !== "object") return false;
24654
+ const data = connection;
24655
+ return data.profile_name === profileName && data.domain === domain;
24656
+ }
24657
+ async function findProfileConnection(k, profileName, domain) {
24658
+ for await (const connection of k.auth.connections.list({ profile_name: profileName, domain })) {
24659
+ if (profileConnectionMatches(connection, profileName, domain)) return connection;
24660
+ }
24661
+ return null;
24662
+ }
24663
+ async function findOrCreateProfileConnection(k, opts) {
24664
+ try {
24665
+ return await k.auth.connections.create({
24666
+ domain: opts.domain,
24667
+ profile_name: opts.profileName,
24668
+ ...opts.loginUrl ? { login_url: opts.loginUrl } : {}
24669
+ });
24670
+ } catch (err) {
24671
+ if (!isProfileConflict(err)) throw err;
24672
+ const existing = await findProfileConnection(k, opts.profileName, opts.domain);
24673
+ if (existing) return existing;
24674
+ throw err;
24675
+ }
24676
+ }
24677
+ function profileOnboardResult(connection, hostedUrl = null, liveViewUrl = null) {
24678
+ return {
24679
+ connectionId: String(connection.id),
24680
+ profileName: String(connection.profile_name),
24681
+ domain: String(connection.domain),
24682
+ status: String(connection.status),
24683
+ flowStatus: typeof connection.flow_status === "string" ? connection.flow_status : null,
24684
+ flowStep: typeof connection.flow_step === "string" ? connection.flow_step : null,
24685
+ flowExpiresAt: typeof connection.flow_expires_at === "string" ? connection.flow_expires_at : null,
24686
+ hostedUrl: hostedUrl ?? (typeof connection.hosted_url === "string" ? connection.hosted_url : null),
24687
+ liveViewUrl: liveViewUrl ?? (typeof connection.live_view_url === "string" ? connection.live_view_url : null),
24688
+ browserSessionId: typeof connection.browser_session_id === "string" ? connection.browser_session_id : null,
24689
+ postLoginUrl: typeof connection.post_login_url === "string" ? connection.post_login_url : null
24690
+ };
24691
+ }
24642
24692
  function explicitProxyId(value) {
24643
24693
  const trimmed = value?.trim();
24644
24694
  return trimmed || void 0;
24645
24695
  }
24696
+ async function startProfileOnboarding(opts) {
24697
+ const k = client();
24698
+ const connection = await findOrCreateProfileConnection(k, opts);
24699
+ const login = await k.auth.connections.login(connection.id);
24700
+ const state = await k.auth.connections.retrieve(connection.id);
24701
+ return profileOnboardResult(state, login.hosted_url ?? null, login.live_view_url ?? null);
24702
+ }
24703
+ async function getProfileOnboardingStatus(input) {
24704
+ const k = client();
24705
+ let connection = null;
24706
+ if (input.connectionId) {
24707
+ connection = await k.auth.connections.retrieve(input.connectionId);
24708
+ } else if (input.profileName && input.domain) {
24709
+ connection = await findProfileConnection(k, input.profileName, input.domain);
24710
+ }
24711
+ if (!connection) throw new Error("profile auth connection not found");
24712
+ return profileOnboardResult(connection);
24713
+ }
24646
24714
  async function createSession(opts = {}) {
24647
24715
  const k = client();
24648
24716
  const resolvedProxyId = explicitProxyId(opts.proxyId);
@@ -25045,6 +25113,56 @@ function buildBrowserAgentRoutes() {
25045
25113
  return next();
25046
25114
  });
25047
25115
  app2.use("*", auth);
25116
+ app2.post("/profiles/onboard", async (c) => {
25117
+ const body = await c.req.json().catch(() => ({}));
25118
+ const profileName = typeof body.profile === "string" ? body.profile.trim() : "";
25119
+ const domain = typeof body.domain === "string" ? body.domain.trim().replace(/^https?:\/\//, "").replace(/\/.*$/, "") : "chatgpt.com";
25120
+ const loginUrl = typeof body.login_url === "string" ? body.login_url.trim() : void 0;
25121
+ if (!profileName) return c.json({ error: "profile is required" }, 400);
25122
+ if (!domain) return c.json({ error: "domain is required" }, 400);
25123
+ try {
25124
+ const result = await startProfileOnboarding({ profileName, domain, loginUrl });
25125
+ return c.json({
25126
+ connection_id: result.connectionId,
25127
+ profile: result.profileName,
25128
+ domain: result.domain,
25129
+ status: result.status,
25130
+ flow_status: result.flowStatus,
25131
+ flow_step: result.flowStep,
25132
+ flow_expires_at: result.flowExpiresAt,
25133
+ hosted_url: result.hostedUrl,
25134
+ live_view_url: result.liveViewUrl,
25135
+ browser_session_id: result.browserSessionId,
25136
+ post_login_url: result.postLoginUrl
25137
+ });
25138
+ } catch (err) {
25139
+ return c.json(failure(err), 502);
25140
+ }
25141
+ });
25142
+ app2.post("/profiles/status", async (c) => {
25143
+ const body = await c.req.json().catch(() => ({}));
25144
+ const connectionId = typeof body.connection_id === "string" ? body.connection_id.trim() : void 0;
25145
+ const profileName = typeof body.profile === "string" ? body.profile.trim() : void 0;
25146
+ const domain = typeof body.domain === "string" ? body.domain.trim().replace(/^https?:\/\//, "").replace(/\/.*$/, "") : void 0;
25147
+ try {
25148
+ const result = await getProfileOnboardingStatus({ connectionId, profileName, domain });
25149
+ return c.json({
25150
+ connection_id: result.connectionId,
25151
+ profile: result.profileName,
25152
+ domain: result.domain,
25153
+ status: result.status,
25154
+ flow_status: result.flowStatus,
25155
+ flow_step: result.flowStep,
25156
+ flow_expires_at: result.flowExpiresAt,
25157
+ hosted_url: result.hostedUrl,
25158
+ live_view_url: result.liveViewUrl,
25159
+ browser_session_id: result.browserSessionId,
25160
+ post_login_url: result.postLoginUrl
25161
+ });
25162
+ } catch (err) {
25163
+ return c.json(failure(err), 404);
25164
+ }
25165
+ });
25048
25166
  app2.post("/sessions", async (c) => {
25049
25167
  const user = c.get("user");
25050
25168
  if (Number(user.balance_mc ?? 0) < BROWSER_OPEN_MIN_BALANCE_MC) {
@@ -25148,6 +25266,7 @@ function buildBrowserAgentRoutes() {
25148
25266
  prompt: typeof body.prompt === "string" ? body.prompt : void 0,
25149
25267
  wait_ms: typeof body.wait_ms === "number" ? body.wait_ms : void 0,
25150
25268
  first_party_domain: typeof body.first_party_domain === "string" ? body.first_party_domain : void 0,
25269
+ reset: body.reset === true,
25151
25270
  export: body.export === true
25152
25271
  };
25153
25272
  const t0 = Date.now();