mcp-scraper 0.2.16 → 0.2.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.
Files changed (32) hide show
  1. package/README.md +12 -5
  2. package/dist/bin/api-server.cjs +479 -7
  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 +466 -1
  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 +9 -7
  15. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  16. package/dist/bin/mcp-scraper-install.js +9 -7
  17. package/dist/bin/mcp-scraper-install.js.map +1 -1
  18. package/dist/bin/mcp-stdio-server.cjs +466 -1
  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-M5SAUO4K.js +7 -0
  22. package/dist/chunk-M5SAUO4K.js.map +1 -0
  23. package/dist/{chunk-ATJAINML.js → chunk-P5PLQU3H.js} +2 -2
  24. package/dist/{chunk-FMC3V54I.js → chunk-RJMCASQH.js} +469 -2
  25. package/dist/chunk-RJMCASQH.js.map +1 -0
  26. package/dist/{server-KSEQLZNP.js → server-VVY5K44O.js} +3 -3
  27. package/package.json +1 -1
  28. package/dist/chunk-FMC3V54I.js.map +0 -1
  29. package/dist/chunk-KE4JZDLV.js +0 -7
  30. package/dist/chunk-KE4JZDLV.js.map +0 -1
  31. /package/dist/{chunk-ATJAINML.js.map → chunk-P5PLQU3H.js.map} +0 -0
  32. /package/dist/{server-KSEQLZNP.js.map → server-VVY5K44O.js.map} +0 -0
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  HttpMcpToolExecutor,
4
4
  buildPaaExtractorMcpServer
5
- } from "../chunk-FMC3V54I.js";
5
+ } from "../chunk-RJMCASQH.js";
6
6
  import "../chunk-M2S27J6Z.js";
7
- import "../chunk-KE4JZDLV.js";
7
+ import "../chunk-M5SAUO4K.js";
8
8
 
9
9
  // bin/mcp-stdio-server.ts
10
10
  import { readFileSync } from "fs";
@@ -0,0 +1,7 @@
1
+ // src/version.ts
2
+ var PACKAGE_VERSION = "0.2.18";
3
+
4
+ export {
5
+ PACKAGE_VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-M5SAUO4K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const PACKAGE_VERSION = '0.2.18'\n"],"mappings":";AAAO,IAAM,kBAAkB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PACKAGE_VERSION
3
- } from "./chunk-KE4JZDLV.js";
3
+ } from "./chunk-M5SAUO4K.js";
4
4
 
5
5
  // src/mcp/browser-agent-mcp-server.ts
6
6
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -790,4 +790,4 @@ export {
790
790
  buildBrowserAgentMcpServer,
791
791
  registerBrowserAgentMcpTools
792
792
  };
793
- //# sourceMappingURL=chunk-ATJAINML.js.map
793
+ //# sourceMappingURL=chunk-P5PLQU3H.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-M2S27J6Z.js";
4
4
  import {
5
5
  PACKAGE_VERSION
6
- } from "./chunk-KE4JZDLV.js";
6
+ } from "./chunk-M5SAUO4K.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}`;
@@ -653,6 +778,163 @@ function normalizeMapsAttempts(value) {
653
778
  observedRegion: attempt.observedRegion ?? attempt.observed_region ?? null
654
779
  }));
655
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
+ }
656
938
  function formatCreditsInfo(raw, input) {
657
939
  const parsed = parseData(raw);
658
940
  if ("error" in parsed) return { content: [{ type: "text", text: parsed.error }], isError: true };
@@ -1523,6 +1805,85 @@ var CreditsInfoInputSchema = {
1523
1805
  item: z.string().optional().describe('Optional tool, action, or feature to look up, e.g. "maps reviews", "extract_url", "YouTube transcription", or "concurrency"'),
1524
1806
  includeLedger: z.boolean().default(false).describe("Whether to include recent credit ledger entries")
1525
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
+ };
1526
1887
  var SearchSerpInputSchema = {
1527
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".'),
1528
1889
  location: z.string().optional().describe("City, region, or country for geo-targeted results, inferred from user request when present."),
@@ -2046,6 +2407,41 @@ function registerPaaExtractorMcpTools(server, executor, options = {}) {
2046
2407
  outputSchema: DirectoryWorkflowOutputSchema,
2047
2408
  annotations: liveWebToolAnnotations("Directory Workflow: Markets + Maps")
2048
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));
2049
2445
  server.registerTool("rank_tracker_blueprint", {
2050
2446
  title: "Rank Tracker Blueprint Builder",
2051
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.",
@@ -2122,6 +2518,57 @@ var HttpMcpToolExecutor = class {
2122
2518
  return { content: [{ type: "text", text: msg }], isError: true };
2123
2519
  }
2124
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
+ }
2125
2572
  harvestPaa(input) {
2126
2573
  const timeoutMs = this.httpTimeoutOverrideMs ?? harvestTimeoutBudget(input.maxQuestions ?? 30).clientMs;
2127
2574
  return this.call("/harvest/sync", input, timeoutMs);
@@ -2169,6 +2616,26 @@ var HttpMcpToolExecutor = class {
2169
2616
  const timeoutMs = this.httpTimeoutOverrideMs ?? Math.min(9e5, Math.max(18e4, Math.ceil(cityCount / concurrency) * 12e4));
2170
2617
  return this.call("/directory/run", input, timeoutMs);
2171
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
+ }
2172
2639
  creditsInfo(input) {
2173
2640
  return this.call("/billing/credits", input);
2174
2641
  }
@@ -2191,4 +2658,4 @@ export {
2191
2658
  registerPaaExtractorMcpTools,
2192
2659
  HttpMcpToolExecutor
2193
2660
  };
2194
- //# sourceMappingURL=chunk-FMC3V54I.js.map
2661
+ //# sourceMappingURL=chunk-RJMCASQH.js.map