mcp-scraper 0.2.15 → 0.2.17

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 (33) hide show
  1. package/README.md +11 -6
  2. package/dist/bin/api-server.cjs +489 -16
  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 +1 -1
  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 +475 -9
  12. package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +1 -1
  13. package/dist/bin/mcp-scraper-combined-stdio-server.js +3 -3
  14. package/dist/bin/mcp-scraper-install.cjs +7 -6
  15. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  16. package/dist/bin/mcp-scraper-install.js +7 -6
  17. package/dist/bin/mcp-scraper-install.js.map +1 -1
  18. package/dist/bin/mcp-stdio-server.cjs +475 -9
  19. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  20. package/dist/bin/mcp-stdio-server.js +2 -2
  21. package/dist/{chunk-Q4DFONIK.js → chunk-BYF7HTLJ.js} +478 -10
  22. package/dist/chunk-BYF7HTLJ.js.map +1 -0
  23. package/dist/chunk-NZG2K6CJ.js +7 -0
  24. package/dist/chunk-NZG2K6CJ.js.map +1 -0
  25. package/dist/{chunk-TIPUIEJN.js → chunk-ZA7IZZKN.js} +2 -2
  26. package/dist/{server-VD2TD3AD.js → server-AK3UME3Y.js} +4 -4
  27. package/dist/server-AK3UME3Y.js.map +1 -0
  28. package/package.json +1 -1
  29. package/dist/chunk-2CQXHSWC.js +0 -7
  30. package/dist/chunk-2CQXHSWC.js.map +0 -1
  31. package/dist/chunk-Q4DFONIK.js.map +0 -1
  32. package/dist/server-VD2TD3AD.js.map +0 -1
  33. /package/dist/{chunk-TIPUIEJN.js.map → chunk-ZA7IZZKN.js.map} +0 -0
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  HttpMcpToolExecutor,
4
4
  buildPaaExtractorMcpServer
5
- } from "../chunk-Q4DFONIK.js";
5
+ } from "../chunk-BYF7HTLJ.js";
6
6
  import "../chunk-M2S27J6Z.js";
7
- import "../chunk-2CQXHSWC.js";
7
+ import "../chunk-NZG2K6CJ.js";
8
8
 
9
9
  // bin/mcp-stdio-server.ts
10
10
  import { readFileSync } from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-M2S27J6Z.js";
4
4
  import {
5
5
  PACKAGE_VERSION
6
- } from "./chunk-2CQXHSWC.js";
6
+ } from "./chunk-NZG2K6CJ.js";
7
7
 
8
8
  // src/harvest-timeout.ts
9
9
  var VERCEL_FUNCTION_MAX_MS = 3e5;
@@ -28,6 +28,123 @@ import { basename, join as join2 } from "path";
28
28
  import { mkdirSync, writeFileSync } from "fs";
29
29
  import { homedir } from "os";
30
30
  import { join } from "path";
31
+
32
+ // src/mcp/workflow-catalog.ts
33
+ var WORKFLOW_RECIPES = [
34
+ {
35
+ id: "market_analysis",
36
+ title: "Market Analysis",
37
+ description: "Compare a niche across a city, state, or market set using Google Maps competitors, SERP evidence, review counts, categories, and opportunity signals.",
38
+ primaryWorkflowId: "local-competitive-audit",
39
+ recommendedTools: ["workflow_run", "directory_workflow", "maps_search", "maps_place_intel", "search_serp", "harvest_paa"],
40
+ requiredInputs: ["query", "state or location"],
41
+ optionalInputs: ["domain", "minPopulation", "maxCities", "maxResultsPerCity", "hydrateTop", "maxReviews"],
42
+ produces: ["city summary", "competitor CSV", "review insight CSV", "market difficulty/opportunity notes", "HTML report"],
43
+ runHint: "Use workflow_run with workflowId local-competitive-audit for state-wide market batches, or map-comparison for one city/location comparison."
44
+ },
45
+ {
46
+ id: "icp_research",
47
+ title: "ICP Research",
48
+ description: "Build an evidence packet for ideal-customer-profile research from real search demand, PAA language, competing pages, AI Overview citations, and source domains.",
49
+ primaryWorkflowId: "agent-packet",
50
+ recommendedTools: ["workflow_run", "harvest_paa", "search_serp", "extract_url", "youtube_harvest", "facebook_ad_search"],
51
+ requiredInputs: ["keyword or audience problem"],
52
+ optionalInputs: ["domain", "location", "maxQuestions"],
53
+ produces: ["evidence JSON", "sources CSV", "competitor CSV", "brief markdown", "agent task list"],
54
+ runHint: "Use workflow_run with workflowId agent-packet. Treat keyword as the buyer problem, job-to-be-done, niche, or service category."
55
+ },
56
+ {
57
+ id: "forum_review_research",
58
+ title: "Forum And Review Research",
59
+ description: "Acquire customer language from Google PAA, forum/Perspectives SERP surfaces, Google Maps reviews, review topics, Facebook ads, and video transcripts.",
60
+ primaryWorkflowId: "local-competitive-audit",
61
+ recommendedTools: ["workflow_run", "harvest_paa", "maps_search", "maps_place_intel", "facebook_page_intel", "facebook_video_transcribe", "youtube_transcribe"],
62
+ requiredInputs: ["query", "state or location"],
63
+ optionalInputs: ["maxReviews", "maxQuestions", "competitors", "facebookUrl", "youtubeVideoId"],
64
+ produces: ["review insight CSV", "PAA/source language", "competitor review topics", "transcripts where supplied", "pain/theme summary"],
65
+ runHint: "Use local-competitive-audit for review acquisition, then harvest_paa for forum/Perspectives language and transcript tools for supplied videos."
66
+ },
67
+ {
68
+ id: "brand_design_brief",
69
+ title: "Brand Design Brief",
70
+ description: "Create a design briefing grounded in a brand site, competitor pages, SERP language, audience pains, visual assets, colors, fonts, screenshots, and positioning evidence.",
71
+ primaryWorkflowId: "serp-comparison",
72
+ recommendedTools: ["workflow_run", "extract_url", "extract_site", "capture_serp_page_snapshots", "search_serp", "harvest_paa", "browser_open"],
73
+ requiredInputs: ["url or domain", "keyword or market category"],
74
+ optionalInputs: ["competitorUrls", "location", "extractTop"],
75
+ produces: ["page comparison CSV", "content gaps", "branding/asset evidence", "SERP positioning evidence", "designer-ready brief"],
76
+ runHint: "Use workflow_run with workflowId serp-comparison for market/page evidence, then extract_url with extractBranding:true for brand assets and colors."
77
+ },
78
+ {
79
+ id: "cro_audit",
80
+ title: "CRO Audit",
81
+ description: "Audit conversion clarity using page extraction, screenshots, browser DOM inspection, competitor SERP/page comparisons, forms/buttons, proof, offer, trust, and friction evidence.",
82
+ primaryWorkflowId: "serp-comparison",
83
+ recommendedTools: ["workflow_run", "extract_url", "extract_site", "capture_serp_page_snapshots", "browser_open", "browser_screenshot", "browser_locate"],
84
+ requiredInputs: ["url"],
85
+ optionalInputs: ["keyword", "domain", "location", "competitorUrls"],
86
+ produces: ["page extraction", "SERP/page comparison", "screenshot evidence", "friction checklist", "CRO recommendations"],
87
+ runHint: "Use workflow_run with workflowId serp-comparison when a keyword/domain is known; use extract_url and browser tools for page-level CRO evidence."
88
+ },
89
+ {
90
+ id: "competitive_positioning_brief",
91
+ title: "Competitive Positioning Brief",
92
+ description: "Compare competitors across SERP, PAA, AI Overview citations, page headings, Facebook ads, YouTube angles, Maps proof, and website claims.",
93
+ primaryWorkflowId: "serp-comparison",
94
+ recommendedTools: ["workflow_run", "facebook_ad_search", "facebook_page_intel", "youtube_harvest", "youtube_transcribe", "maps_search", "extract_url"],
95
+ requiredInputs: ["keyword or query", "domain or url"],
96
+ optionalInputs: ["location", "extractTop", "competitorUrls", "brandNames"],
97
+ produces: ["SERP comparison", "content gap CSV", "AI Overview citation table", "competitor message map", "positioning brief"],
98
+ runHint: "Use workflow_run with workflowId serp-comparison, then enrich with Facebook, YouTube, and Maps tools when the user asks for campaign or offer positioning."
99
+ },
100
+ {
101
+ id: "content_gap_brief",
102
+ title: "Content Gap Brief",
103
+ description: "Turn live SERP, page extraction, PAA questions, AI Overview citations, and source-domain evidence into a writer-ready content brief.",
104
+ primaryWorkflowId: "serp-comparison",
105
+ recommendedTools: ["workflow_run", "paa-expansion-brief", "harvest_paa", "extract_url"],
106
+ requiredInputs: ["keyword"],
107
+ optionalInputs: ["domain", "url", "location", "maxQuestions", "extractTop"],
108
+ produces: ["content gaps", "page comparison CSV", "PAA questions CSV", "section map", "writer brief"],
109
+ runHint: "Use workflow_run with workflowId serp-comparison for competitor gaps or paa-expansion-brief when the user mainly wants a section map from PAA data."
110
+ },
111
+ {
112
+ id: "ai_search_visibility_audit",
113
+ title: "AI Search Visibility Audit",
114
+ description: "Audit whether a brand/domain appears in AI Overview citations, PAA sources, organic results, local pack, and source pages, then produce language guidance.",
115
+ primaryWorkflowId: "ai-overview-language",
116
+ recommendedTools: ["workflow_run", "search_serp", "harvest_paa", "extract_url", "capture_serp_snapshot"],
117
+ requiredInputs: ["keyword", "domain or url"],
118
+ optionalInputs: ["location", "maxQuestions", "extractTop"],
119
+ produces: ["AI Overview citations CSV", "claim patterns", "language guidance", "citation hooks", "visibility gaps"],
120
+ runHint: "Use workflow_run with workflowId ai-overview-language. Use serp-comparison when the user also wants ranking-page gaps."
121
+ }
122
+ ];
123
+ function normalize(value) {
124
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
125
+ }
126
+ function suggestWorkflowRecipes(goal, limit = 3) {
127
+ const normalized = normalize(goal);
128
+ const scored = WORKFLOW_RECIPES.map((recipe) => {
129
+ const haystack = normalize([
130
+ recipe.id,
131
+ recipe.title,
132
+ recipe.description,
133
+ recipe.requiredInputs.join(" "),
134
+ recipe.optionalInputs.join(" "),
135
+ recipe.produces.join(" ")
136
+ ].join(" "));
137
+ let score = 0;
138
+ for (const token of normalized.split(/\s+/).filter(Boolean)) {
139
+ if (haystack.includes(token)) score += 1;
140
+ }
141
+ if (haystack.includes(normalized)) score += 5;
142
+ return { recipe, score };
143
+ });
144
+ return scored.sort((a, b) => b.score - a.score || a.recipe.title.localeCompare(b.recipe.title)).slice(0, Math.max(1, limit)).map((item) => item.recipe);
145
+ }
146
+
147
+ // src/mcp/mcp-response-formatter.ts
31
148
  var reportSavingEnabled = true;
32
149
  function configureReportSaving(enabled) {
33
150
  reportSavingEnabled = enabled;
@@ -81,6 +198,14 @@ function oneBlock(content) {
81
198
  \u{1F4C4} Saved: \`${filePath}\`` : content;
82
199
  return { content: [{ type: "text", text }] };
83
200
  }
201
+ function workflowRecipeTable(recipes) {
202
+ if (!recipes.length) return "";
203
+ return [
204
+ "| Recipe | Best workflow | What it produces |",
205
+ "|---|---|---|",
206
+ ...recipes.map((recipe) => `| ${cell(recipe.title)} | ${recipe.primaryWorkflowId ? `\`${recipe.primaryWorkflowId}\`` : "tool chain"} | ${cell(recipe.produces.slice(0, 4).join(", "))} |`)
207
+ ].join("\n");
208
+ }
84
209
  function formatStructuredError(body, fallback) {
85
210
  if (body.error === "insufficient_balance") {
86
211
  return `Insufficient credits. Balance: ${body.balance_credits} credits. This call requires ${body.required_credits} credits. Top up at ${body.topup_url}`;
@@ -570,7 +695,8 @@ ${adBlocks}`,
570
695
  `
571
696
  ---
572
697
  \u{1F4A1} **Tips**
573
- - Transcribe video ads: use \`facebook_ad_transcribe\` with the \`videoUrl\` above
698
+ - Transcribe video ads: use \`facebook_ad_transcribe\` with the direct \`videoUrl\` above
699
+ - Transcribe organic Facebook reels/posts: use \`facebook_video_transcribe\` with the public Facebook URL
574
700
  - Find other advertisers: use \`facebook_ad_search\``
575
701
  ].filter(Boolean).join("\n");
576
702
  return {
@@ -652,6 +778,163 @@ function normalizeMapsAttempts(value) {
652
778
  observedRegion: attempt.observedRegion ?? attempt.observed_region ?? null
653
779
  }));
654
780
  }
781
+ function workflowArtifactsFrom(run) {
782
+ return Array.isArray(run?.artifacts) ? run.artifacts : [];
783
+ }
784
+ function workflowArtifactRows(artifacts) {
785
+ if (!artifacts.length) return "";
786
+ return [
787
+ "| Artifact | Type | ID | Rows/Bytes |",
788
+ "|---|---|---|---|",
789
+ ...artifacts.map((artifact) => {
790
+ const rows = artifact.rows_count ?? artifact.rows ?? "";
791
+ const bytes = artifact.bytes ?? "";
792
+ const size = [rows ? `${rows} rows` : "", bytes ? `${bytes} bytes` : ""].filter(Boolean).join(" / ");
793
+ return `| ${cell(String(artifact.label ?? artifact.path ?? "artifact"))} | ${cell(String(artifact.kind ?? artifact.content_type ?? "file"))} | \`${String(artifact.id ?? "")}\` | ${cell(size || "\u2014")} |`;
794
+ })
795
+ ].join("\n");
796
+ }
797
+ function formatWorkflowList(raw, input) {
798
+ const parsed = parseData(raw);
799
+ if ("error" in parsed) return { content: [{ type: "text", text: parsed.error }], isError: true };
800
+ const workflows = Array.isArray(parsed.data.workflows) ? parsed.data.workflows : [];
801
+ const workflowRows = [
802
+ "| Workflow ID | Title | Use |",
803
+ "|---|---|---|",
804
+ ...workflows.map((workflow) => `| \`${String(workflow.id ?? "")}\` | ${cell(String(workflow.title ?? ""))} | ${cell(String(workflow.description ?? ""))} |`)
805
+ ].join("\n");
806
+ const recipes = input.includeRecipes === false ? [] : WORKFLOW_RECIPES;
807
+ const full = [
808
+ "# MCP Scraper Workflows",
809
+ "Use `workflow_suggest` when the user describes a high-level job. Use `workflow_run` when the workflow id and input are known. Use `workflow_status` and `workflow_artifact_read` to inspect completed runs and pull evidence back into context.",
810
+ workflows.length ? `
811
+ ## Runnable Workflows
812
+ ${workflowRows}` : "",
813
+ recipes.length ? `
814
+ ## High-Level Recipes
815
+ ${workflowRecipeTable(recipes)}` : "",
816
+ recipes.length ? "\nThese recipes cover market analysis, ICP research, forum and review acquisition, brand design briefings, CRO audits, competitive positioning, content gaps, and AI search visibility audits." : ""
817
+ ].filter(Boolean).join("\n");
818
+ return {
819
+ ...oneBlock(full),
820
+ structuredContent: {
821
+ workflows: workflows.map((workflow) => ({
822
+ id: String(workflow.id ?? ""),
823
+ title: String(workflow.title ?? ""),
824
+ description: String(workflow.description ?? "")
825
+ })),
826
+ recipes
827
+ }
828
+ };
829
+ }
830
+ function formatWorkflowSuggest(input) {
831
+ const suggestions = suggestWorkflowRecipes(input.goal, input.maxSuggestions ?? 3);
832
+ const full = [
833
+ `# Workflow Suggestions`,
834
+ `**Goal:** ${input.goal}`,
835
+ "",
836
+ workflowRecipeTable(suggestions),
837
+ "",
838
+ "## How To Execute",
839
+ "1. Pick the closest recipe.",
840
+ "2. If it has a `primaryWorkflowId`, call `workflow_run` with that id and the required inputs.",
841
+ "3. After the run completes, use `workflow_artifact_read` on the most relevant CSV/JSON/Markdown artifacts before writing the final answer."
842
+ ].join("\n");
843
+ return {
844
+ ...oneBlock(full),
845
+ structuredContent: {
846
+ goal: input.goal,
847
+ suggestions
848
+ }
849
+ };
850
+ }
851
+ function formatWorkflowRun(raw, input) {
852
+ const parsed = parseData(raw);
853
+ if ("error" in parsed) return { content: [{ type: "text", text: parsed.error }], isError: true };
854
+ const run = parsed.data.run;
855
+ const summary = parsed.data.summary;
856
+ const artifacts = workflowArtifactsFrom(run);
857
+ const runId = String(run?.id ?? "");
858
+ const status = String(run?.status ?? summary?.status ?? "unknown");
859
+ const full = [
860
+ `# Workflow Run: ${input.workflowId}`,
861
+ `**Run ID:** \`${runId || "unknown"}\``,
862
+ `**Status:** ${status}`,
863
+ summary?.title ? `**Title:** ${summary.title}` : "",
864
+ summary?.summary ? `
865
+ ## Summary
866
+ ${summary.summary}` : "",
867
+ artifacts.length ? `
868
+ ## Artifacts
869
+ ${workflowArtifactRows(artifacts)}` : "",
870
+ artifacts.length ? "\nUse `workflow_artifact_read` with the run id and artifact id to pull CSV, JSON, Markdown, or report content into context." : ""
871
+ ].filter(Boolean).join("\n");
872
+ return {
873
+ ...oneBlock(full),
874
+ structuredContent: {
875
+ workflowId: input.workflowId,
876
+ input: input.input ?? {},
877
+ run,
878
+ summary,
879
+ artifacts
880
+ }
881
+ };
882
+ }
883
+ function formatWorkflowStatus(raw, input) {
884
+ const parsed = parseData(raw);
885
+ if ("error" in parsed) return { content: [{ type: "text", text: parsed.error }], isError: true };
886
+ const run = parsed.data.run;
887
+ const artifacts = workflowArtifactsFrom(run);
888
+ const full = [
889
+ `# Workflow Status`,
890
+ `**Run ID:** \`${input.runId}\``,
891
+ `**Workflow:** ${run?.workflow_id ?? "unknown"}`,
892
+ `**Status:** ${run?.status ?? "unknown"}`,
893
+ run?.error_message ? `
894
+ ## Error
895
+ ${run.error_message}` : "",
896
+ artifacts.length ? `
897
+ ## Artifacts
898
+ ${workflowArtifactRows(artifacts)}` : ""
899
+ ].filter(Boolean).join("\n");
900
+ return {
901
+ ...oneBlock(full),
902
+ structuredContent: {
903
+ run,
904
+ artifacts
905
+ }
906
+ };
907
+ }
908
+ function formatWorkflowArtifactRead(raw, input) {
909
+ const parsed = parseData(raw);
910
+ if ("error" in parsed) return { content: [{ type: "text", text: parsed.error }], isError: true };
911
+ const text = typeof parsed.data.text === "string" ? parsed.data.text : "";
912
+ const contentType = String(parsed.data.contentType ?? "text/plain");
913
+ const bytes = Number(parsed.data.bytes ?? 0);
914
+ const truncated = parsed.data.truncated === true;
915
+ const full = [
916
+ `# Workflow Artifact`,
917
+ `**Run ID:** \`${input.runId}\``,
918
+ `**Artifact ID:** \`${input.artifactId}\``,
919
+ `**Content-Type:** ${contentType}`,
920
+ `**Bytes:** ${bytes}${truncated ? ` (truncated to ${input.maxBytes ?? 2e5})` : ""}`,
921
+ "",
922
+ "```",
923
+ text,
924
+ "```"
925
+ ].join("\n");
926
+ return {
927
+ ...oneBlock(full),
928
+ structuredContent: {
929
+ runId: input.runId,
930
+ artifactId: input.artifactId,
931
+ contentType,
932
+ bytes,
933
+ truncated,
934
+ text
935
+ }
936
+ };
937
+ }
655
938
  function formatCreditsInfo(raw, input) {
656
939
  const parsed = parseData(raw);
657
940
  if ("error" in parsed) return { content: [{ type: "text", text: parsed.error }], isError: true };
@@ -1016,7 +1299,7 @@ ${text}`,
1016
1299
  ${chunkRows}` : "",
1017
1300
  `
1018
1301
  ---
1019
- \u{1F4A1} Get more ads from this advertiser: use \`facebook_page_intel\``
1302
+ \u{1F4A1} Get more ads from this advertiser: use \`facebook_page_intel\`. For public Facebook reel/post URLs, use \`facebook_video_transcribe\`.`
1020
1303
  ].filter(Boolean).join("\n");
1021
1304
  return oneBlock(full);
1022
1305
  }
@@ -1052,7 +1335,7 @@ ${text}`,
1052
1335
  ${chunkRows}` : "",
1053
1336
  `
1054
1337
  ---
1055
- \u{1F4A1} To download the extracted MP4, call the Facebook media endpoint with the extracted MP4 URL.`
1338
+ \u{1F4A1} Use \`videoUrl\` as the extracted MP4 for download or follow-up processing. Use \`facebook_ad_transcribe\` only for Ad Library videoUrl values.`
1056
1339
  ].filter(Boolean).join("\n");
1057
1340
  return {
1058
1341
  ...oneBlock(full),
@@ -1129,10 +1412,10 @@ var FacebookAdSearchInputSchema = {
1129
1412
  maxResults: z.number().int().min(1).max(20).default(10)
1130
1413
  };
1131
1414
  var FacebookAdTranscribeInputSchema = {
1132
- videoUrl: z.string().url().describe("Facebook CDN video URL from a facebook_page_intel result")
1415
+ videoUrl: z.string().url().describe("Direct Facebook CDN video URL from a facebook_page_intel ad result. Do not pass a public Facebook reel/post/share URL here; use facebook_video_transcribe for organic Facebook URLs.")
1133
1416
  };
1134
1417
  var FacebookVideoTranscribeInputSchema = {
1135
- url: z.string().url().describe("Organic Facebook reel, video, watch, or share URL. The tool renders the page, extracts the best public Facebook CDN MP4 URL, then transcribes it."),
1418
+ url: z.string().url().describe("Organic Facebook reel, video, watch, post, or share URL from facebook.com, m.facebook.com, or fb.watch. The tool renders the page, extracts the best matching public Facebook CDN MP4 URL, then transcribes it. Use this when the user pastes a normal Facebook video page URL and asks for the transcript or downloadable MP4."),
1136
1419
  quality: z.enum(["best", "hd", "sd"]).default("best").describe("Preferred progressive MP4 quality. Use best by default; hd prefers the highest HD progressive URL; sd forces the SD URL.")
1137
1420
  };
1138
1421
  var MapsPlaceIntelInputSchema = {
@@ -1522,6 +1805,85 @@ var CreditsInfoInputSchema = {
1522
1805
  item: z.string().optional().describe('Optional tool, action, or feature to look up, e.g. "maps reviews", "extract_url", "YouTube transcription", or "concurrency"'),
1523
1806
  includeLedger: z.boolean().default(false).describe("Whether to include recent credit ledger entries")
1524
1807
  };
1808
+ var WorkflowIdSchema = z.enum([
1809
+ "directory",
1810
+ "agent-packet",
1811
+ "local-competitive-audit",
1812
+ "map-comparison",
1813
+ "serp-comparison",
1814
+ "paa-expansion-brief",
1815
+ "ai-overview-language"
1816
+ ]);
1817
+ var WorkflowListInputSchema = {
1818
+ includeRecipes: z.boolean().default(true).describe("Include high-level AI-facing recipes such as market analysis, ICP research, forum/review research, brand design briefings, CRO audits, positioning briefs, content gaps, and AI search visibility audits.")
1819
+ };
1820
+ var WorkflowSuggestInputSchema = {
1821
+ goal: z.string().min(1).describe('The user goal or job to route, e.g. "market analysis for roofers in Tennessee", "ICP research for med spas", "CRO audit for this URL", or "brand design briefing".'),
1822
+ query: z.string().optional().describe("Business category, niche, or Maps query when known."),
1823
+ keyword: z.string().optional().describe("Search keyword, audience problem, or content topic when known."),
1824
+ domain: z.string().optional().describe("Target domain or brand domain when known."),
1825
+ url: z.string().url().optional().describe("Target URL when the workflow should inspect a specific page."),
1826
+ location: z.string().optional().describe("City/region/country for localized research, e.g. Denver, CO."),
1827
+ state: z.string().optional().describe("US state abbreviation or name for state-wide market research."),
1828
+ maxSuggestions: z.number().int().min(1).max(8).default(3).describe("Number of matching workflow recipes to return.")
1829
+ };
1830
+ var WorkflowRunInputSchema = {
1831
+ workflowId: WorkflowIdSchema.describe("Workflow to run. Use workflow_list or workflow_suggest first when unsure."),
1832
+ input: z.record(z.unknown()).default({}).describe("Workflow-specific input object. Examples: agent-packet uses {keyword, domain?, location?, maxQuestions?}; local-competitive-audit uses {query, state, minPopulation?, maxCities?, maxResultsPerCity?, hydrateTop?, maxReviews?}; serp-comparison uses {keyword, domain?, url?, location?, extractTop?}."),
1833
+ webhookUrl: z.string().url().optional().describe("Optional HTTPS webhook to receive the completed hosted workflow run event.")
1834
+ };
1835
+ var WorkflowStatusInputSchema = {
1836
+ runId: z.string().min(1).describe("Workflow run id returned by workflow_run.")
1837
+ };
1838
+ var WorkflowArtifactReadInputSchema = {
1839
+ runId: z.string().min(1).describe("Workflow run id returned by workflow_run or workflow_status."),
1840
+ artifactId: z.string().min(1).describe("Artifact id from the run artifact list."),
1841
+ maxBytes: z.number().int().min(1e3).max(1e6).default(2e5).describe("Maximum bytes of artifact text to return inline. Use lower values for large CSV/JSON artifacts; call again with the downloadUrl if needed outside MCP.")
1842
+ };
1843
+ var WorkflowRecipeOutput = z.object({
1844
+ id: z.string(),
1845
+ title: z.string(),
1846
+ description: z.string(),
1847
+ primaryWorkflowId: z.string().nullable(),
1848
+ recommendedTools: z.array(z.string()),
1849
+ requiredInputs: z.array(z.string()),
1850
+ optionalInputs: z.array(z.string()),
1851
+ produces: z.array(z.string()),
1852
+ runHint: z.string()
1853
+ });
1854
+ var WorkflowDefinitionOutput = z.object({
1855
+ id: z.string(),
1856
+ title: z.string(),
1857
+ description: z.string()
1858
+ });
1859
+ var WorkflowArtifactOutput = z.record(z.unknown());
1860
+ var WorkflowListOutputSchema = {
1861
+ workflows: z.array(WorkflowDefinitionOutput),
1862
+ recipes: z.array(WorkflowRecipeOutput)
1863
+ };
1864
+ var WorkflowSuggestOutputSchema = {
1865
+ goal: z.string(),
1866
+ suggestions: z.array(WorkflowRecipeOutput)
1867
+ };
1868
+ var WorkflowRunOutputSchema = {
1869
+ workflowId: z.string(),
1870
+ input: z.record(z.unknown()),
1871
+ run: z.record(z.unknown()).optional(),
1872
+ summary: z.record(z.unknown()).optional(),
1873
+ artifacts: z.array(WorkflowArtifactOutput)
1874
+ };
1875
+ var WorkflowStatusOutputSchema = {
1876
+ run: z.record(z.unknown()).optional(),
1877
+ artifacts: z.array(WorkflowArtifactOutput)
1878
+ };
1879
+ var WorkflowArtifactReadOutputSchema = {
1880
+ runId: z.string(),
1881
+ artifactId: z.string(),
1882
+ contentType: z.string(),
1883
+ bytes: z.number().int().min(0),
1884
+ truncated: z.boolean(),
1885
+ text: z.string()
1886
+ };
1525
1887
  var SearchSerpInputSchema = {
1526
1888
  query: z.string().min(1).describe('Core search topic only. Separate location when possible. If user says "best dentist in Brooklyn NY serp", use query="best dentist" and location="Brooklyn, NY".'),
1527
1889
  location: z.string().optional().describe("City, region, or country for geo-targeted results, inferred from user request when present."),
@@ -1999,7 +2361,7 @@ function registerPaaExtractorMcpTools(server, executor, options = {}) {
1999
2361
  }, async (input) => formatYoutubeTranscribe(await executor.youtubeTranscribe(input), input));
2000
2362
  server.registerTool("facebook_page_intel", {
2001
2363
  title: "Facebook Advertiser Ad Intel",
2002
- description: withReportNote("Harvest ads from a Facebook advertiser. Returns ad copy, headlines, CTAs, creative type, status, landing URLs, and video URLs ready for transcription. Accepts pageId, libraryId, or a brand/advertiser name as query. Use after facebook_ad_search when possible."),
2364
+ description: withReportNote("Harvest ads from a Facebook advertiser. Returns ad copy, headlines, CTAs, creative type, status, landing URLs, and direct ad video URLs ready for facebook_ad_transcribe. Accepts pageId, libraryId, or a brand/advertiser name as query. Use after facebook_ad_search when possible. For normal public Facebook reels/posts/watch/share URLs, use facebook_video_transcribe instead."),
2003
2365
  inputSchema: FacebookPageIntelInputSchema,
2004
2366
  outputSchema: FacebookPageIntelOutputSchema,
2005
2367
  annotations: liveWebToolAnnotations("Facebook Advertiser Ad Intel")
@@ -2013,13 +2375,13 @@ function registerPaaExtractorMcpTools(server, executor, options = {}) {
2013
2375
  }, async (input) => formatFacebookAdSearch(await executor.facebookAdSearch(input), input));
2014
2376
  server.registerTool("facebook_ad_transcribe", {
2015
2377
  title: "Facebook Ad Transcription",
2016
- description: "Transcribe audio from a Facebook ad video. Returns full transcript and timestamped chunks. Use the videoUrl value from facebook_page_intel results.",
2378
+ description: "Transcribe audio from a Facebook ad video CDN URL. Returns full transcript and timestamped chunks. Use only with the direct videoUrl value from facebook_page_intel results, not public Facebook post/reel/share URLs.",
2017
2379
  inputSchema: FacebookAdTranscribeInputSchema,
2018
2380
  annotations: liveWebToolAnnotations("Facebook Ad Transcription")
2019
2381
  }, async (input) => formatFacebookAdTranscribe(await executor.facebookAdTranscribe(input), input));
2020
2382
  server.registerTool("facebook_video_transcribe", {
2021
2383
  title: "Facebook Organic Video Transcription",
2022
- description: withReportNote("Transcribe audio from an organic Facebook reel, video, watch, or share URL. Renders the Facebook page, extracts the best public Facebook CDN MP4 URL from the page state, then returns the full transcript, timestamped chunks, and extracted MP4 URL."),
2384
+ description: withReportNote("Transcribe audio from an organic Facebook reel, video, watch, post, or share URL, including fb.watch links. Use this when the user pastes a normal Facebook video page URL and wants the transcript or downloadable MP4. Renders the Facebook page in a browser, selects the best matching public Facebook CDN MP4 URL from page state, then returns sourceUrl, resolved pageUrl, videoId, ownerName, selectedQuality, bitrate, videoDurationSec, extracted MP4 URL, full transcript, and timestamped chunks."),
2023
2385
  inputSchema: FacebookVideoTranscribeInputSchema,
2024
2386
  outputSchema: FacebookVideoTranscribeOutputSchema,
2025
2387
  annotations: liveWebToolAnnotations("Facebook Organic Video Transcription")
@@ -2045,6 +2407,41 @@ function registerPaaExtractorMcpTools(server, executor, options = {}) {
2045
2407
  outputSchema: DirectoryWorkflowOutputSchema,
2046
2408
  annotations: liveWebToolAnnotations("Directory Workflow: Markets + Maps")
2047
2409
  }, async (input) => formatDirectoryWorkflow(await executor.directoryWorkflow(input), input));
2410
+ server.registerTool("workflow_list", {
2411
+ title: "Workflow Catalog",
2412
+ description: "List MCP Scraper higher-level workflows and AI-facing recipes. Use this when the user asks what MCP Scraper can do beyond single tools, or asks for market analysis, ICP research, forum/review acquisition, full brand design briefings, CRO audits, competitive positioning, content gap briefs, or AI search visibility audits. Returns runnable workflow ids plus recipe guidance for the best tool chain.",
2413
+ inputSchema: WorkflowListInputSchema,
2414
+ outputSchema: WorkflowListOutputSchema,
2415
+ annotations: localPlanningToolAnnotations("Workflow Catalog")
2416
+ }, async (input) => formatWorkflowList(await executor.workflowList(input), input));
2417
+ server.registerTool("workflow_suggest", {
2418
+ title: "Workflow Intent Router",
2419
+ description: 'Route a high-level business or research goal to the right MCP Scraper workflow/tool chain. Use before running work when the user says things like "do market analysis", "research my ICP", "acquire forum and review language", "build a brand design brief", "run a CRO audit", "compare competitors", "make a content gap brief", or "audit AI search visibility". This tool does not spend credits; it tells the AI exactly which workflow/tool chain to run next.',
2420
+ inputSchema: WorkflowSuggestInputSchema,
2421
+ outputSchema: WorkflowSuggestOutputSchema,
2422
+ annotations: localPlanningToolAnnotations("Workflow Intent Router")
2423
+ }, async (input) => formatWorkflowSuggest(input));
2424
+ server.registerTool("workflow_run", {
2425
+ title: "Run Workflow",
2426
+ description: withReportNote("Run a higher-level MCP Scraper workflow and return the run id, summary, and artifacts. Use after workflow_suggest or workflow_list. Runnable workflow ids: directory, agent-packet, local-competitive-audit, map-comparison, serp-comparison, paa-expansion-brief, ai-overview-language. This is the main MCP tool for executing market analysis, ICP evidence packets, local competitive audits, Maps/SERP comparisons, content gap briefs, and AI Overview language guidance."),
2427
+ inputSchema: WorkflowRunInputSchema,
2428
+ outputSchema: WorkflowRunOutputSchema,
2429
+ annotations: liveWebToolAnnotations("Run Workflow")
2430
+ }, async (input) => formatWorkflowRun(await executor.workflowRun(input), input));
2431
+ server.registerTool("workflow_status", {
2432
+ title: "Workflow Status",
2433
+ description: "Fetch a hosted workflow run by id and list its current status and artifacts. Use after workflow_run when the model needs to re-open a run, inspect artifact ids, or recover from a long workflow.",
2434
+ inputSchema: WorkflowStatusInputSchema,
2435
+ outputSchema: WorkflowStatusOutputSchema,
2436
+ annotations: liveWebToolAnnotations("Workflow Status")
2437
+ }, async (input) => formatWorkflowStatus(await executor.workflowStatus(input), input));
2438
+ server.registerTool("workflow_artifact_read", {
2439
+ title: "Read Workflow Artifact",
2440
+ description: "Read a workflow artifact back into MCP context by run id and artifact id. Use this before writing final deliverables so the answer is grounded in generated evidence.json, CSVs, Markdown briefs, reports, and task files instead of memory. Use maxBytes to limit large CSV/JSON artifacts.",
2441
+ inputSchema: WorkflowArtifactReadInputSchema,
2442
+ outputSchema: WorkflowArtifactReadOutputSchema,
2443
+ annotations: liveWebToolAnnotations("Read Workflow Artifact")
2444
+ }, async (input) => formatWorkflowArtifactRead(await executor.workflowArtifactRead(input), input));
2048
2445
  server.registerTool("rank_tracker_blueprint", {
2049
2446
  title: "Rank Tracker Blueprint Builder",
2050
2447
  description: "Generate a build-ready database, cron/heartbeat, ingestion, metrics, and AI implementation prompt for a rank tracker powered by MCP Scraper. Supports Maps rankings through directory_workflow/maps_search, organic rankings through search_serp, AI Overview citation tracking, and People Also Ask source presence tracking. This tool is local planning only; it does not call the web or spend credits.",
@@ -2121,6 +2518,57 @@ var HttpMcpToolExecutor = class {
2121
2518
  return { content: [{ type: "text", text: msg }], isError: true };
2122
2519
  }
2123
2520
  }
2521
+ async getJson(path, timeoutMs = this.timeoutMs) {
2522
+ try {
2523
+ const res = await fetch(`${this.baseUrl}${path}`, {
2524
+ method: "GET",
2525
+ headers: {
2526
+ "x-api-key": this.apiKey
2527
+ },
2528
+ signal: AbortSignal.timeout(timeoutMs)
2529
+ });
2530
+ const data = await res.json();
2531
+ if (!res.ok) {
2532
+ return { content: [{ type: "text", text: JSON.stringify(data) }], isError: true };
2533
+ }
2534
+ return { content: [{ type: "text", text: JSON.stringify(data) }] };
2535
+ } catch (err) {
2536
+ const msg = err instanceof Error ? err.message : String(err);
2537
+ return { content: [{ type: "text", text: msg }], isError: true };
2538
+ }
2539
+ }
2540
+ async getTextArtifact(path, maxBytes, timeoutMs = this.timeoutMs) {
2541
+ try {
2542
+ const res = await fetch(`${this.baseUrl}${path}`, {
2543
+ method: "GET",
2544
+ headers: {
2545
+ "x-api-key": this.apiKey
2546
+ },
2547
+ signal: AbortSignal.timeout(timeoutMs)
2548
+ });
2549
+ if (!res.ok) {
2550
+ const data = await res.json().catch(async () => ({ error: await res.text().catch(() => `HTTP ${res.status}`) }));
2551
+ return { content: [{ type: "text", text: JSON.stringify(data) }], isError: true };
2552
+ }
2553
+ const bytes = Buffer.from(await res.arrayBuffer());
2554
+ const sliced = bytes.subarray(0, Math.min(maxBytes, bytes.length));
2555
+ return {
2556
+ content: [{
2557
+ type: "text",
2558
+ text: JSON.stringify({
2559
+ contentType: res.headers.get("content-type") ?? "application/octet-stream",
2560
+ bytes: bytes.length,
2561
+ truncated: sliced.length < bytes.length,
2562
+ maxBytes,
2563
+ text: sliced.toString("utf8")
2564
+ })
2565
+ }]
2566
+ };
2567
+ } catch (err) {
2568
+ const msg = err instanceof Error ? err.message : String(err);
2569
+ return { content: [{ type: "text", text: msg }], isError: true };
2570
+ }
2571
+ }
2124
2572
  harvestPaa(input) {
2125
2573
  const timeoutMs = this.httpTimeoutOverrideMs ?? harvestTimeoutBudget(input.maxQuestions ?? 30).clientMs;
2126
2574
  return this.call("/harvest/sync", input, timeoutMs);
@@ -2168,6 +2616,26 @@ var HttpMcpToolExecutor = class {
2168
2616
  const timeoutMs = this.httpTimeoutOverrideMs ?? Math.min(9e5, Math.max(18e4, Math.ceil(cityCount / concurrency) * 12e4));
2169
2617
  return this.call("/directory/run", input, timeoutMs);
2170
2618
  }
2619
+ workflowList(_input) {
2620
+ return this.getJson("/workflows/definitions");
2621
+ }
2622
+ workflowRun(input) {
2623
+ const timeoutMs = this.httpTimeoutOverrideMs ?? Number(process.env.MCP_SCRAPER_WORKFLOW_TIMEOUT_MS ?? 9e5);
2624
+ return this.call("/workflows/run", {
2625
+ workflowId: input.workflowId,
2626
+ input: input.input ?? {},
2627
+ webhookUrl: input.webhookUrl
2628
+ }, Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 9e5);
2629
+ }
2630
+ workflowStatus(input) {
2631
+ return this.getJson(`/workflows/runs/${encodeURIComponent(input.runId)}`);
2632
+ }
2633
+ workflowArtifactRead(input) {
2634
+ return this.getTextArtifact(
2635
+ `/workflows/runs/${encodeURIComponent(input.runId)}/artifacts/${encodeURIComponent(input.artifactId)}`,
2636
+ input.maxBytes ?? 2e5
2637
+ );
2638
+ }
2171
2639
  creditsInfo(input) {
2172
2640
  return this.call("/billing/credits", input);
2173
2641
  }
@@ -2190,4 +2658,4 @@ export {
2190
2658
  registerPaaExtractorMcpTools,
2191
2659
  HttpMcpToolExecutor
2192
2660
  };
2193
- //# sourceMappingURL=chunk-Q4DFONIK.js.map
2661
+ //# sourceMappingURL=chunk-BYF7HTLJ.js.map