mcp-scraper 0.88.2 → 0.89.1

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 (84) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/README.md +6 -3
  3. package/dist/analytics-repository-J25XR5E7.js +1 -0
  4. package/dist/bin/api-server.js +2 -41
  5. package/dist/bin/mcp-scraper-cli.js +39 -756
  6. package/dist/bin/mcp-scraper-core.js +1 -60
  7. package/dist/bin/mcp-scraper-install.js +2 -25
  8. package/dist/bin/mcp-stdio-server.js +1 -19
  9. package/dist/bin/paa-harvest.js +1 -41
  10. package/dist/chunk-3GP5CYZX.js +1 -0
  11. package/dist/chunk-4FROKQJN.js +1 -0
  12. package/dist/chunk-57AHYL2O.js +20 -0
  13. package/dist/chunk-5H3MCTTP.js +1 -0
  14. package/dist/chunk-63T4W2LX.js +1271 -0
  15. package/dist/chunk-645LQBE7.js +2595 -0
  16. package/dist/chunk-6QO4F2KC.js +21710 -0
  17. package/dist/chunk-CCYWSJNG.js +16 -0
  18. package/dist/chunk-D6IQJP64.js +84 -0
  19. package/dist/chunk-DGBLGFNJ.js +182 -0
  20. package/dist/chunk-FFPD2DOF.js +59 -0
  21. package/dist/chunk-FXEWHK54.js +1 -0
  22. package/dist/chunk-HE45FFBU.js +1 -0
  23. package/dist/chunk-HUV2WTRW.js +1 -0
  24. package/dist/chunk-IJ2AO7AO.js +102 -0
  25. package/dist/chunk-KJQXUZ4Y.js +4 -0
  26. package/dist/chunk-MEM4D2QN.js +1280 -0
  27. package/dist/chunk-MZN4U5BL.js +1 -0
  28. package/dist/chunk-PRWZNHQB.js +1 -0
  29. package/dist/chunk-QPWPR5XG.js +10 -0
  30. package/dist/chunk-RYNHNEF3.js +73 -0
  31. package/dist/chunk-TMB56NCA.js +1 -0
  32. package/dist/chunk-W2BVJ7S2.js +13 -0
  33. package/dist/chunk-WO3N5FH2.js +5 -0
  34. package/dist/chunk-XLWNEVUZ.js +27 -0
  35. package/dist/chunk-YQZGZBB4.js +1 -0
  36. package/dist/chunk-YUPLOOTB.js +4 -0
  37. package/dist/chunk-ZHORX44A.js +100 -0
  38. package/dist/db-JJWJLAVQ.js +1 -0
  39. package/dist/extract-bundle-TTSEGWYF.js +26 -0
  40. package/dist/gmail-service-34PIJRLK.js +1 -0
  41. package/dist/index.cjs +21838 -6034
  42. package/dist/index.js +18 -315
  43. package/dist/lead-list-enrichment-repository-VJBBMBCG.js +1 -0
  44. package/dist/location-data-repository-W3LPT6G3.js +1 -0
  45. package/dist/server-UEY5YQL6.js +7329 -0
  46. package/dist/site-extract-repository-7W5ZUNPR.js +1 -0
  47. package/dist/worker-ZOTOKG56.js +1 -0
  48. package/package.json +11 -4
  49. package/dist/analytics-repository-GGJJCVVP.js +0 -194
  50. package/dist/chunk-4QMUF6XM.js +0 -1013
  51. package/dist/chunk-6HAV7LCE.js +0 -265
  52. package/dist/chunk-ABF2CGOZ.js +0 -113
  53. package/dist/chunk-C5Z4OFKW.js +0 -404
  54. package/dist/chunk-DNM65UCK.js +0 -299
  55. package/dist/chunk-EQGTEHLZ.js +0 -592
  56. package/dist/chunk-F5GQJWZU.js +0 -732
  57. package/dist/chunk-GGZEC22A.js +0 -215
  58. package/dist/chunk-GXBZXWXB.js +0 -184
  59. package/dist/chunk-IHXAXYIS.js +0 -843
  60. package/dist/chunk-K3Z5AQYE.js +0 -683
  61. package/dist/chunk-K45K75OF.js +0 -6
  62. package/dist/chunk-LFW2FRPJ.js +0 -224
  63. package/dist/chunk-MZDNZQWT.js +0 -2078
  64. package/dist/chunk-NVUKO5NN.js +0 -256
  65. package/dist/chunk-OM7HVEJ3.js +0 -26
  66. package/dist/chunk-OPQIGAFB.js +0 -286
  67. package/dist/chunk-OZJMVCDK.js +0 -16
  68. package/dist/chunk-P7FWOMU7.js +0 -505
  69. package/dist/chunk-PGJQDMC2.js +0 -383
  70. package/dist/chunk-PKZS6SHW.js +0 -33139
  71. package/dist/chunk-RJ7JVYKU.js +0 -68
  72. package/dist/chunk-S24LFPL7.js +0 -5262
  73. package/dist/chunk-T3MZISOF.js +0 -240
  74. package/dist/chunk-UZPTGUDV.js +0 -1915
  75. package/dist/chunk-X623GTBV.js +0 -8290
  76. package/dist/chunk-YXNDOQXN.js +0 -4018
  77. package/dist/db-Z34LPZNR.js +0 -284
  78. package/dist/extract-bundle-565SBZCR.js +0 -1003
  79. package/dist/gmail-service-E6ALS7JG.js +0 -25
  80. package/dist/lead-list-enrichment-repository-36RPVV6N.js +0 -67
  81. package/dist/location-data-repository-WPRG62GE.js +0 -34
  82. package/dist/server-SQZ3A7SY.js +0 -86606
  83. package/dist/site-extract-repository-VYFZASPU.js +0 -69
  84. 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
- };