mcp-scraper 0.88.2 → 0.89.0

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 (87) hide show
  1. package/CHANGELOG.md +36 -15
  2. package/README.md +6 -5
  3. package/THIRD_PARTY_NOTICES.html +203 -0
  4. package/dist/analytics-repository-2BMT5JNE.js +1 -0
  5. package/dist/bin/api-server.js +2 -41
  6. package/dist/bin/mcp-scraper-cli.js +39 -756
  7. package/dist/bin/mcp-scraper-core.js +1 -60
  8. package/dist/bin/mcp-scraper-install.js +2 -25
  9. package/dist/bin/mcp-stdio-server.js +1 -19
  10. package/dist/bin/paa-harvest.js +1 -41
  11. package/dist/chunk-3GP5CYZX.js +1 -0
  12. package/dist/chunk-4AI7DOS7.js +59 -0
  13. package/dist/chunk-4FROKQJN.js +1 -0
  14. package/dist/chunk-7YGVI5J4.js +21710 -0
  15. package/dist/chunk-CCYWSJNG.js +16 -0
  16. package/dist/chunk-CFI6CXIV.js +182 -0
  17. package/dist/chunk-E2WRWV3A.js +1 -0
  18. package/dist/chunk-GMWKPIYX.js +1172 -0
  19. package/dist/chunk-HDPYG3XV.js +102 -0
  20. package/dist/chunk-HE45FFBU.js +1 -0
  21. package/dist/chunk-HUV2WTRW.js +1 -0
  22. package/dist/chunk-KJQXUZ4Y.js +4 -0
  23. package/dist/chunk-L4CGLFPU.js +4 -0
  24. package/dist/chunk-M22MM4N4.js +84 -0
  25. package/dist/chunk-MASR22K4.js +73 -0
  26. package/dist/chunk-MZN4U5BL.js +1 -0
  27. package/dist/chunk-PUHFVA7P.js +1280 -0
  28. package/dist/chunk-QPWPR5XG.js +10 -0
  29. package/dist/chunk-TMB56NCA.js +1 -0
  30. package/dist/chunk-TXENITMS.js +20 -0
  31. package/dist/chunk-W2BVJ7S2.js +13 -0
  32. package/dist/chunk-WO3N5FH2.js +5 -0
  33. package/dist/chunk-WSCGYRWA.js +2595 -0
  34. package/dist/chunk-X54CQLK2.js +1 -0
  35. package/dist/chunk-XLWNEVUZ.js +27 -0
  36. package/dist/chunk-XPZVJIZ2.js +100 -0
  37. package/dist/chunk-YQZGZBB4.js +1 -0
  38. package/dist/chunk-Z2QGQJS2.js +1 -0
  39. package/dist/db-F2MX63GI.js +1 -0
  40. package/dist/extract-bundle-SNUIHM3J.js +26 -0
  41. package/dist/gmail-service-BZ3H75XC.js +1 -0
  42. package/dist/index.cjs +21750 -6045
  43. package/dist/index.d.cts +14 -14
  44. package/dist/index.d.ts +14 -14
  45. package/dist/index.js +18 -315
  46. package/dist/lead-list-enrichment-repository-S2H3U7T7.js +1 -0
  47. package/dist/location-data-repository-OTWHWMV6.js +1 -0
  48. package/dist/server-RFR2A5UJ.js +7303 -0
  49. package/dist/site-extract-repository-SE776XDC.js +1 -0
  50. package/dist/worker-XUDSM3AL.js +1 -0
  51. package/package.json +17 -124
  52. package/dist/analytics-repository-GGJJCVVP.js +0 -194
  53. package/dist/chunk-4QMUF6XM.js +0 -1013
  54. package/dist/chunk-6HAV7LCE.js +0 -265
  55. package/dist/chunk-ABF2CGOZ.js +0 -113
  56. package/dist/chunk-C5Z4OFKW.js +0 -404
  57. package/dist/chunk-DNM65UCK.js +0 -299
  58. package/dist/chunk-EQGTEHLZ.js +0 -592
  59. package/dist/chunk-F5GQJWZU.js +0 -732
  60. package/dist/chunk-GGZEC22A.js +0 -215
  61. package/dist/chunk-GXBZXWXB.js +0 -184
  62. package/dist/chunk-IHXAXYIS.js +0 -843
  63. package/dist/chunk-K3Z5AQYE.js +0 -683
  64. package/dist/chunk-K45K75OF.js +0 -6
  65. package/dist/chunk-LFW2FRPJ.js +0 -224
  66. package/dist/chunk-MZDNZQWT.js +0 -2078
  67. package/dist/chunk-NVUKO5NN.js +0 -256
  68. package/dist/chunk-OM7HVEJ3.js +0 -26
  69. package/dist/chunk-OPQIGAFB.js +0 -286
  70. package/dist/chunk-OZJMVCDK.js +0 -16
  71. package/dist/chunk-P7FWOMU7.js +0 -505
  72. package/dist/chunk-PGJQDMC2.js +0 -383
  73. package/dist/chunk-PKZS6SHW.js +0 -33139
  74. package/dist/chunk-RJ7JVYKU.js +0 -68
  75. package/dist/chunk-S24LFPL7.js +0 -5262
  76. package/dist/chunk-T3MZISOF.js +0 -240
  77. package/dist/chunk-UZPTGUDV.js +0 -1915
  78. package/dist/chunk-X623GTBV.js +0 -8290
  79. package/dist/chunk-YXNDOQXN.js +0 -4018
  80. package/dist/db-Z34LPZNR.js +0 -284
  81. package/dist/extract-bundle-565SBZCR.js +0 -1003
  82. package/dist/gmail-service-E6ALS7JG.js +0 -25
  83. package/dist/lead-list-enrichment-repository-36RPVV6N.js +0 -67
  84. package/dist/location-data-repository-WPRG62GE.js +0 -34
  85. package/dist/server-SQZ3A7SY.js +0 -86606
  86. package/dist/site-extract-repository-VYFZASPU.js +0 -69
  87. package/dist/worker-LDCAULWL.js +0 -146
@@ -1,224 +0,0 @@
1
- import {
2
- HttpMcpToolExecutor,
3
- MEMORY_TOOL_REGISTRY,
4
- SERVER_INSTRUCTIONS,
5
- ScheduledResultsMcpExecutor,
6
- hashOwnerId,
7
- installInputFieldDescriptions,
8
- permitsLocalNetworkAccess,
9
- registerBrowserAgentMcpTools,
10
- registerMemoryMcpTools,
11
- registerPaaExtractorMcpTools,
12
- registerScheduledResultsMcpTools,
13
- registerSerpIntelligenceCaptureTools,
14
- resolveDeploymentProfile
15
- } from "./chunk-PKZS6SHW.js";
16
- import {
17
- renderInstallTerminal
18
- } from "./chunk-ABF2CGOZ.js";
19
- import {
20
- PACKAGE_VERSION
21
- } from "./chunk-K45K75OF.js";
22
-
23
- // src/mcp/stdio-runtime.ts
24
- import { readFileSync } from "fs";
25
- import { homedir } from "os";
26
- import { join } from "path";
27
- import { serveStdio } from "@modelcontextprotocol/server/stdio";
28
- import { McpServer } from "@modelcontextprotocol/server";
29
-
30
- // src/mcp/hosted-memory-mcp-tool-executor.ts
31
- var publicToolNameByUpstreamName = new Map(
32
- MEMORY_TOOL_REGISTRY.map((schema) => [schema.upstreamName, schema.id])
33
- );
34
- function parseJsonRpcEnvelope(text) {
35
- const payloads = text.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).filter(Boolean);
36
- if (!payloads.length) return JSON.parse(text);
37
- for (const payload of payloads) {
38
- const parsed = JSON.parse(payload);
39
- if (parsed.result || parsed.error) return parsed;
40
- }
41
- throw new Error("hosted MCP returned no JSON-RPC result");
42
- }
43
- function errorResult(message) {
44
- return {
45
- content: [{ type: "text", text: JSON.stringify({ ok: false, error: message }) }],
46
- isError: true
47
- };
48
- }
49
- var HostedMemoryMcpToolExecutor = class {
50
- baseUrl;
51
- apiKey;
52
- constructor(baseUrl, apiKey) {
53
- this.baseUrl = baseUrl.replace(/\/$/, "");
54
- this.apiKey = apiKey;
55
- }
56
- async callMemoryTool(upstreamName, args) {
57
- const publicToolName = publicToolNameByUpstreamName.get(upstreamName);
58
- if (!publicToolName) return errorResult(`unknown memory tool: ${upstreamName}`);
59
- try {
60
- const res = await fetch(`${this.baseUrl}/mcp`, {
61
- method: "POST",
62
- headers: {
63
- "content-type": "application/json",
64
- accept: "application/json, text/event-stream",
65
- "x-api-key": this.apiKey
66
- },
67
- body: JSON.stringify({
68
- jsonrpc: "2.0",
69
- id: `memory:${publicToolName}`,
70
- method: "tools/call",
71
- params: { name: publicToolName, arguments: args }
72
- })
73
- });
74
- const text = await res.text();
75
- if (!res.ok) return errorResult(`hosted memory ${publicToolName} failed (HTTP ${res.status})`);
76
- const envelope = parseJsonRpcEnvelope(text);
77
- if (envelope.error) {
78
- return errorResult(envelope.error.message ?? `hosted memory ${publicToolName} failed`);
79
- }
80
- return envelope.result ?? errorResult(`hosted memory ${publicToolName} returned no result`);
81
- } catch (err) {
82
- return errorResult(err instanceof Error ? err.message : `hosted memory ${publicToolName} call failed`);
83
- }
84
- }
85
- };
86
-
87
- // src/mcp/exact-tool-registration.ts
88
- function installExactToolRegistrationGuard(server, requiredToolNames) {
89
- if (requiredToolNames.length === 0) {
90
- throw new Error("Restricted MCP tool allowlist must contain at least one tool name");
91
- }
92
- const required = /* @__PURE__ */ new Set();
93
- for (const rawName of requiredToolNames) {
94
- if (typeof rawName !== "string" || rawName.trim() !== rawName || rawName.length === 0) {
95
- throw new Error("Restricted MCP tool allowlist contains a malformed tool name");
96
- }
97
- if (required.has(rawName)) {
98
- throw new Error(`Restricted MCP tool allowlist contains duplicate tool name: ${rawName}`);
99
- }
100
- required.add(rawName);
101
- }
102
- const registered = /* @__PURE__ */ new Set();
103
- const mutableServer = server;
104
- const registerTool = mutableServer.registerTool.bind(server);
105
- mutableServer.registerTool = (name, config, callback) => {
106
- if (!required.has(name)) return void 0;
107
- registered.add(name);
108
- return registerTool(name, config, callback);
109
- };
110
- return {
111
- assertComplete() {
112
- const missing = [...required].filter((name) => !registered.has(name));
113
- if (missing.length > 0) {
114
- throw new Error(`Restricted MCP tool allowlist contains unknown or unavailable tool names: ${missing.join(", ")}`);
115
- }
116
- },
117
- registeredToolNames() {
118
- return [...registered];
119
- }
120
- };
121
- }
122
-
123
- // src/mcp/stdio-runtime.ts
124
- var ALL_STDIO_TOOLSETS = /* @__PURE__ */ new Set([
125
- "paa",
126
- "serp",
127
- "browser-agent",
128
- "scheduled-results",
129
- "memory"
130
- ]);
131
- function readApiKeyFile() {
132
- const explicitPath = process.env.MCP_SCRAPER_KEY_PATH?.trim();
133
- const fileNames = [explicitPath, join(homedir(), ".mcp-scraper-key")].filter(Boolean);
134
- for (const fileName of fileNames) {
135
- try {
136
- const value = readFileSync(fileName, "utf8").trim();
137
- if (value) return value;
138
- } catch {
139
- }
140
- }
141
- return void 0;
142
- }
143
- function buildStdioServer(requiredApiKey, options = {}) {
144
- const toolsets = options.toolsets ?? ALL_STDIO_TOOLSETS;
145
- const baseUrl = process.env.MCP_SCRAPER_BASE_URL?.trim() || process.env.MCP_BASE_URL?.trim() || "https://mcpscraper.dev";
146
- const deploymentProfile = resolveDeploymentProfile();
147
- const localNetworkAccess = permitsLocalNetworkAccess({
148
- deploymentProfile,
149
- transportProfile: "stdio",
150
- baseUrl,
151
- explicitlyEnabled: process.env.MCP_SCRAPER_ALLOW_PRIVATE_NETWORK === "1"
152
- });
153
- const consoleBaseUrl = process.env.BROWSER_AGENT_CONSOLE_URL?.trim() || baseUrl;
154
- const server = new McpServer({ name: "mcp-scraper", version: PACKAGE_VERSION }, {
155
- instructions: SERVER_INSTRUCTIONS,
156
- cacheHints: {
157
- "server/discover": { ttlMs: 3e5, cacheScope: "private" },
158
- "tools/list": { ttlMs: 3e5, cacheScope: "private" },
159
- "prompts/list": { ttlMs: 3e5, cacheScope: "private" },
160
- "resources/list": { ttlMs: 3e5, cacheScope: "private" },
161
- "resources/templates/list": { ttlMs: 3e5, cacheScope: "private" },
162
- "resources/read": { ttlMs: 6e4, cacheScope: "private" }
163
- }
164
- });
165
- installInputFieldDescriptions(server);
166
- const registrationGuard = options.allowedToolNames ? installExactToolRegistrationGuard(server, options.allowedToolNames) : void 0;
167
- const httpExecutor = options.httpExecutor ?? new HttpMcpToolExecutor(baseUrl, requiredApiKey, { localNetworkAccess });
168
- if (toolsets.has("paa")) {
169
- registerPaaExtractorMcpTools(server, httpExecutor, {
170
- ownerId: hashOwnerId(requiredApiKey),
171
- deploymentProfile,
172
- transportProfile: "stdio",
173
- baseUrl,
174
- localNetworkAccess,
175
- taskHandleSecret: requiredApiKey
176
- });
177
- }
178
- if (toolsets.has("serp")) {
179
- registerSerpIntelligenceCaptureTools(server, httpExecutor, {
180
- exposeDevelopmentDiagnostics: deploymentProfile === "development" || deploymentProfile === "test"
181
- });
182
- }
183
- if (toolsets.has("browser-agent")) {
184
- registerBrowserAgentMcpTools(server, { baseUrl, apiKey: requiredApiKey, consoleBaseUrl });
185
- }
186
- if (toolsets.has("scheduled-results")) {
187
- registerScheduledResultsMcpTools(server, new ScheduledResultsMcpExecutor(baseUrl, requiredApiKey));
188
- }
189
- if (toolsets.has("memory")) {
190
- registerMemoryMcpTools(server, new HostedMemoryMcpToolExecutor(baseUrl, requiredApiKey));
191
- }
192
- registrationGuard?.assertComplete();
193
- return server;
194
- }
195
- function runMcpScraperStdio(options = {}) {
196
- const forceStdio = process.argv.includes("--stdio") || process.env.MCP_SCRAPER_FORCE_STDIO === "1";
197
- const interactiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
198
- const wantsHelp = process.argv.includes("--help") || process.argv.includes("-h");
199
- if (!forceStdio && (interactiveTerminal || wantsHelp)) {
200
- const noColor = process.argv.includes("--no-color") || process.env.NO_COLOR !== void 0 || process.env.FORCE_COLOR === "0" || !process.stdout.isTTY;
201
- process.stdout.write(renderInstallTerminal({
202
- version: PACKAGE_VERSION,
203
- color: !noColor,
204
- apiKeyConfigured: Boolean(process.env.MCP_SCRAPER_API_KEY?.trim())
205
- }));
206
- process.exit(0);
207
- }
208
- const apiKey = (process.env.MCP_SCRAPER_API_KEY ?? process.env.MCP_SCRAPER_KEY ?? process.env.MCP_API_KEY ?? readApiKeyFile())?.trim();
209
- if (!apiKey) {
210
- process.stderr.write("MCP_SCRAPER_API_KEY env var or ~/.mcp-scraper-key is required\n");
211
- process.exit(1);
212
- }
213
- serveStdio(() => buildStdioServer(apiKey, options), {
214
- legacy: "serve",
215
- onerror(error) {
216
- process.stderr.write(`${error.message}
217
- `);
218
- }
219
- });
220
- }
221
-
222
- export {
223
- runMcpScraperStdio
224
- };