@fouradata/mcp 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +258 -0
- package/bin/foura-mcp.js +2 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +32 -0
- package/dist/auth.js.map +1 -0
- package/dist/http.d.ts +1 -0
- package/dist/http.js +182 -0
- package/dist/http.js.map +1 -0
- package/dist/prompts.d.ts +11 -0
- package/dist/prompts.js +149 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +33 -0
- package/dist/resources.js +126 -0
- package/dist/resources.js.map +1 -0
- package/dist/safe-target.d.ts +5 -0
- package/dist/safe-target.js +130 -0
- package/dist/safe-target.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/stdio.js +7 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tools/browser.d.ts +77 -0
- package/dist/tools/browser.js +316 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/proxy.d.ts +113 -0
- package/dist/tools/proxy.js +379 -0
- package/dist/tools/proxy.js.map +1 -0
- package/dist/tools/single.d.ts +79 -0
- package/dist/tools/single.js +374 -0
- package/dist/tools/single.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { request } from "undici";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { getApiKey } from "../auth.js";
|
|
4
|
+
import { assertPublicTarget, SsrfBlockedError } from "../safe-target.js";
|
|
5
|
+
import { storePayload, THRESHOLD_BYTES } from "../resources.js";
|
|
6
|
+
function extractContentTypeFromHeaderInfo(headers) {
|
|
7
|
+
if (!Array.isArray(headers))
|
|
8
|
+
return null;
|
|
9
|
+
for (const h of headers) {
|
|
10
|
+
if (h && typeof h === "object") {
|
|
11
|
+
const entries = Object.entries(h);
|
|
12
|
+
for (const [k, v] of entries) {
|
|
13
|
+
if (k.toLowerCase() === "content-type") {
|
|
14
|
+
const value = Array.isArray(v) ? v[0] : v;
|
|
15
|
+
if (typeof value === "string")
|
|
16
|
+
return value.split(";")[0]?.trim() ?? null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function deriveCode(status, envelope) {
|
|
24
|
+
if (status === 400)
|
|
25
|
+
return "bad_request";
|
|
26
|
+
if (status === 401)
|
|
27
|
+
return "auth_failed";
|
|
28
|
+
if (status === 403)
|
|
29
|
+
return "forbidden";
|
|
30
|
+
if (status === 404)
|
|
31
|
+
return "not_found";
|
|
32
|
+
if (status === 429)
|
|
33
|
+
return "rate_limited";
|
|
34
|
+
if (status === 503) {
|
|
35
|
+
if (envelope.current)
|
|
36
|
+
return "at_capacity";
|
|
37
|
+
const err = typeof envelope.error === "string" ? envelope.error : "";
|
|
38
|
+
if (err.toLowerCase().includes("disabled"))
|
|
39
|
+
return "service_disabled";
|
|
40
|
+
return "service_unavailable";
|
|
41
|
+
}
|
|
42
|
+
if (status >= 500)
|
|
43
|
+
return "upstream_error";
|
|
44
|
+
if (status >= 400)
|
|
45
|
+
return "upstream_client_error";
|
|
46
|
+
return "upstream_unknown";
|
|
47
|
+
}
|
|
48
|
+
async function guardHandler(service,
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
outputSchema,
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
fn) {
|
|
53
|
+
try {
|
|
54
|
+
const result = await fn();
|
|
55
|
+
if (result?.structuredContent) {
|
|
56
|
+
const parsed = outputSchema.safeParse(result.structuredContent);
|
|
57
|
+
if (!parsed.success) {
|
|
58
|
+
const issues = parsed.error.issues.slice(0, 5).map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
59
|
+
return {
|
|
60
|
+
isError: true,
|
|
61
|
+
content: [{ type: "text", text: `FourA ${service} — upstream response failed schema: ${issues}` }],
|
|
62
|
+
structuredContent: {
|
|
63
|
+
service,
|
|
64
|
+
code: "output_validation_failed",
|
|
65
|
+
error: `Upstream response did not match the expected schema: ${issues}`,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
74
|
+
return {
|
|
75
|
+
isError: true,
|
|
76
|
+
content: [{ type: "text", text: `FourA ${service} — internal error: ${msg}` }],
|
|
77
|
+
structuredContent: {
|
|
78
|
+
service,
|
|
79
|
+
code: "output_validation_failed",
|
|
80
|
+
error: `Tool handler crashed before producing a response: ${msg}`,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const PROXY_API_URL = (process.env.FOURA_API_BASE ?? "https://api.foura.ai/api") + "/proxy/";
|
|
86
|
+
const ProxyValidateSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
status: z
|
|
89
|
+
.object({
|
|
90
|
+
accept: z.array(z.number().int()).optional().describe("HTTP status codes to treat as success"),
|
|
91
|
+
fail: z.array(z.number().int()).optional().describe("HTTP status codes to treat as failure"),
|
|
92
|
+
})
|
|
93
|
+
.optional(),
|
|
94
|
+
headers: z
|
|
95
|
+
.object({
|
|
96
|
+
accept: z
|
|
97
|
+
.record(z.string(), z.string())
|
|
98
|
+
.optional()
|
|
99
|
+
.describe("Map of header-name-substring → header-value-substring (both case-insensitive). Response PASSES if AT LEAST ONE entry matches (header name contains the key AND value contains the value). Checked across all redirect hops. Empty / omitted = no header requirement."),
|
|
100
|
+
fail: z
|
|
101
|
+
.record(z.string(), z.string())
|
|
102
|
+
.optional()
|
|
103
|
+
.describe("Map of header-name-substring → header-value-substring (both case-insensitive). Response is treated as FAILURE if ANY entry matches a response header. Use to reject challenge / block headers, e.g. {\"x-blocked\": \"bot\", \"server\": \"cloudflare\"}."),
|
|
104
|
+
})
|
|
105
|
+
.optional(),
|
|
106
|
+
data: z
|
|
107
|
+
.object({
|
|
108
|
+
accept: z.array(z.string()).optional(),
|
|
109
|
+
fail: z.array(z.string()).optional(),
|
|
110
|
+
})
|
|
111
|
+
.optional(),
|
|
112
|
+
})
|
|
113
|
+
.optional();
|
|
114
|
+
// Inner DwRequest — matches dwstack types/src/single.ts DwRequestSchema
|
|
115
|
+
// (which is what /api/proxy/ inner.request validates against). Method is
|
|
116
|
+
// permissive z.string() not enum (Bug 9). All optionals match upstream.
|
|
117
|
+
const ProxyInnerRequestSchema = z
|
|
118
|
+
.object({
|
|
119
|
+
method: z
|
|
120
|
+
.string()
|
|
121
|
+
.min(1)
|
|
122
|
+
.describe("HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, or any WebDAV verb)"),
|
|
123
|
+
url: z
|
|
124
|
+
.string()
|
|
125
|
+
.url()
|
|
126
|
+
.describe("Target URL the proxy should fetch. Public hosts only — private/reserved ranges (RFC 1918 + loopback + link-local + IPv6 ULA/loopback + *.local mDNS) are refused with code `ssrf_blocked`. Example: https://shop.example.com/pricing for blocked sites. {ts} placeholder is replaced with current Unix timestamp."),
|
|
127
|
+
headers: z
|
|
128
|
+
.array(z.tuple([z.string(), z.string()]))
|
|
129
|
+
.optional()
|
|
130
|
+
.describe("Custom HTTP headers as [name, value] tuples. Example: [[\"Referer\", \"https://google.com/\"]]"),
|
|
131
|
+
unblocker: z
|
|
132
|
+
.boolean()
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("Inject realistic browser headers (User-Agent, Sec-Ch-Ua, Accept-Encoding, …) and make the request look like it's coming from a real browser at the wire level. Default false — STRONGLY recommended on proxy paths since most sites that need a proxy also have wire-level anti-bot (Cloudflare, Akamai, PerimeterX, Datadome). Cheap to leave on for production scrapes."),
|
|
135
|
+
data: z
|
|
136
|
+
.union([z.string(), z.record(z.string(), z.unknown())])
|
|
137
|
+
.optional()
|
|
138
|
+
.describe("Request body."),
|
|
139
|
+
timeout_ms: z.number().int().min(0).max(120_000).optional().describe("Per-attempt timeout in ms"),
|
|
140
|
+
connect_timeout_ms: z.number().int().min(0).max(120_000).optional(),
|
|
141
|
+
accept_timeout_ms: z.number().int().min(0).max(120_000).optional(),
|
|
142
|
+
server_response_timeout_ms: z.number().int().min(0).max(120_000).optional(),
|
|
143
|
+
dns_cache_timeout_sec: z.number().int().min(0).max(240).optional(),
|
|
144
|
+
followRedirects: z.number().int().min(0).max(20).optional(),
|
|
145
|
+
tryJsonData: z.boolean().optional(),
|
|
146
|
+
returnBuffer: z.boolean().optional(),
|
|
147
|
+
validate: ProxyValidateSchema,
|
|
148
|
+
})
|
|
149
|
+
.describe("The inner HTTP request to send through each proxy attempt. Validation rules here determine when a proxy is treated as failed and retried.");
|
|
150
|
+
// HeaderInfo[] — same as single. Multi-value headers (Set-Cookie, Link)
|
|
151
|
+
// come as string OR string[] from node-libcurl — Bug 1 fix.
|
|
152
|
+
const ProxyHeaderInfoSchema = z
|
|
153
|
+
.object({
|
|
154
|
+
result: z
|
|
155
|
+
.object({
|
|
156
|
+
version: z.string().optional(),
|
|
157
|
+
code: z.number().int().optional(),
|
|
158
|
+
reason: z.string().optional(),
|
|
159
|
+
})
|
|
160
|
+
.optional(),
|
|
161
|
+
})
|
|
162
|
+
.catchall(z.union([z.string(), z.array(z.string())]));
|
|
163
|
+
const proxyOutputShape = {
|
|
164
|
+
// Success — PrResponse = DwResponse + {proxy, total}. The backend type
|
|
165
|
+
// also has an optional `proxyId` (number), but the api gateway encodes it
|
|
166
|
+
// into the `proxy` string and strips it from the response. We don't
|
|
167
|
+
// surface it in outputSchema — zod silently drops any stray copy.
|
|
168
|
+
status: z.number().int().optional().describe("HTTP status code from the target (from the succeeding proxy attempt). `0` indicates every attempt failed before any HTTP response (DNS / connection refused / timeout) — check the `error` field for the underlying reason."),
|
|
169
|
+
headers: z
|
|
170
|
+
.union([z.array(ProxyHeaderInfoSchema), z.string(), z.record(z.string(), z.unknown())])
|
|
171
|
+
.optional()
|
|
172
|
+
.describe("Response headers per redirect hop, as an array of objects. Each entry has `result.{version, code, reason}` plus arbitrary header-name keys whose values are strings (or arrays of strings for multi-value headers like Set-Cookie / Link)."),
|
|
173
|
+
data: z.unknown().optional().describe("Decoded response body. Omitted when offloaded."),
|
|
174
|
+
// total_time can be string | number | null per dwstack types — Bug 6 fix.
|
|
175
|
+
total_time: z
|
|
176
|
+
.union([z.number(), z.string(), z.null()])
|
|
177
|
+
.optional()
|
|
178
|
+
.describe("Per-attempt wall-clock duration of the succeeding inner request"),
|
|
179
|
+
proxy: z
|
|
180
|
+
.string()
|
|
181
|
+
.optional()
|
|
182
|
+
.describe("Base36 ID of the pool exit that succeeded (e.g. `4DZ3VE`). Reuse on next call: " +
|
|
183
|
+
"pass to foura_single.proxy or foura_browser.proxy → same exit IP. " +
|
|
184
|
+
"Pass to foura_proxy.ignoreProxies → skip this exit on future rotations."),
|
|
185
|
+
total: z
|
|
186
|
+
.number()
|
|
187
|
+
.optional()
|
|
188
|
+
.describe("Outer total time in seconds (proxy selection + retries + the successful inner attempt). Float."),
|
|
189
|
+
// Offload path — MCP layer adds these when body >= 50KB AND offload_large=true
|
|
190
|
+
offloaded_resource_uri: z.string().optional().describe("foura-mcp://payload/<uuid>"),
|
|
191
|
+
size_bytes: z.number().int().optional().describe("Total offloaded body size in bytes"),
|
|
192
|
+
// Error path — includes PrResponseError shape: {error, request, total} (no status, no headers, no data)
|
|
193
|
+
error: z.string().optional().describe("Human-readable error message"),
|
|
194
|
+
service: z.enum(["single", "proxy", "browser", "api"]).optional(),
|
|
195
|
+
retryAfter: z.number().optional(),
|
|
196
|
+
current: z
|
|
197
|
+
.object({ concurrency: z.number().optional(), rpm: z.number().optional() })
|
|
198
|
+
.optional(),
|
|
199
|
+
limits: z
|
|
200
|
+
.object({ maxConcurrency: z.number().optional(), maxRpm: z.number().optional() })
|
|
201
|
+
.optional(),
|
|
202
|
+
request: z.unknown().optional().describe("Echoed PrRequest from upstream PrResponseError"),
|
|
203
|
+
code: z.string().optional().describe("Stable error code for retry classification. One of: ssrf_blocked, upstream_non_json, output_validation_failed, bad_request (400), auth_failed (401), forbidden (403), not_found (404), rate_limited (429), at_capacity (503), service_disabled (503), service_unavailable (503), upstream_error (>=500), upstream_client_error (other 4xx), upstream_unknown (defensive)."),
|
|
204
|
+
};
|
|
205
|
+
const proxyInputShape = {
|
|
206
|
+
request: ProxyInnerRequestSchema,
|
|
207
|
+
// PrRequestSchema.timeout_ms is `.positive()` in upstream — 0 is invalid here
|
|
208
|
+
// (different from single's .min(0)).
|
|
209
|
+
maxTries: z
|
|
210
|
+
.number()
|
|
211
|
+
.int()
|
|
212
|
+
.min(1)
|
|
213
|
+
.max(90)
|
|
214
|
+
.optional()
|
|
215
|
+
.describe("Maximum proxy rotation attempts before giving up (default 5, max 90). Default 5 is sized for lightly-blocked sites. Raise to 25-30 for tier-1 WAF challenges (Vercel Security Checkpoint, Cloudflare 'Just a moment', Akamai Bot Manager) — most rotations on these targets need this range. If still blocked after 30 attempts, the gate is likely country / ASN allowlist (not solvable by rotation) — pivot strategy instead of climbing to 60."),
|
|
216
|
+
timeout_ms: z
|
|
217
|
+
.number()
|
|
218
|
+
.int()
|
|
219
|
+
.positive()
|
|
220
|
+
.max(120_000)
|
|
221
|
+
.optional()
|
|
222
|
+
.describe("Overall timeout across all rotation attempts in ms (default 45000, max 120000). Must be positive."),
|
|
223
|
+
ignoreProxies: z
|
|
224
|
+
.array(z.string())
|
|
225
|
+
.optional()
|
|
226
|
+
.describe("Encoded proxy IDs (base36 strings like \"4DZ3VE\") OR proxy URLs to exclude from rotation. Both forms are accepted."),
|
|
227
|
+
// Bug 3 fix — opt-in offload, default false (inline).
|
|
228
|
+
offload_large: z
|
|
229
|
+
.boolean()
|
|
230
|
+
.optional()
|
|
231
|
+
.describe("If true, response bodies >= 50KB are written to disk and returned as a resource_link instead of inlined. Default false."),
|
|
232
|
+
};
|
|
233
|
+
export function registerProxyTool(server) {
|
|
234
|
+
server.registerTool("foura_proxy", {
|
|
235
|
+
title: "FourA — HTTP request via rotating proxies",
|
|
236
|
+
description: "Route an HTTP request through FourA's proxy pool with automatic retry across multiple proxies. " +
|
|
237
|
+
"Per-host proxy rating picks proxies most likely to succeed for the target. Use when foura_single " +
|
|
238
|
+
"returns 403, captcha, or geo-blocked content. Typical latency 1–5s. The response includes the " +
|
|
239
|
+
"encoded proxy ID that succeeded ('proxy' field) — reuse it in foura_single.proxy or " +
|
|
240
|
+
"foura_browser.proxy to pin follow-up requests to the same exit IP, or pass it in ignoreProxies " +
|
|
241
|
+
"to skip this exit on the next rotation. Escalate to foura_browser if all proxies fail or the " +
|
|
242
|
+
"page needs JavaScript rendering. When the trigger is a tier-1 WAF challenge (Vercel Security " +
|
|
243
|
+
"Checkpoint, Cloudflare 'Just a moment', Akamai Bot Manager), set maxTries to 25-30 — the default " +
|
|
244
|
+
"5 will usually be too low for these targets. Distinguish from country / ASN allowlist denials " +
|
|
245
|
+
"(country-licensed bookmakers, government sites): there rotation never helps regardless of " +
|
|
246
|
+
"maxTries — after ~30 failed attempts on the same block, stop climbing and pivot strategy instead.",
|
|
247
|
+
inputSchema: proxyInputShape,
|
|
248
|
+
outputSchema: proxyOutputShape,
|
|
249
|
+
annotations: {
|
|
250
|
+
readOnlyHint: true,
|
|
251
|
+
destructiveHint: false,
|
|
252
|
+
openWorldHint: true,
|
|
253
|
+
},
|
|
254
|
+
}, async (input) => guardHandler("proxy", z.object(proxyOutputShape), async () => {
|
|
255
|
+
try {
|
|
256
|
+
await assertPublicTarget(input.request.url);
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
if (e instanceof SsrfBlockedError) {
|
|
260
|
+
return {
|
|
261
|
+
isError: true,
|
|
262
|
+
content: [{ type: "text", text: e.message }],
|
|
263
|
+
structuredContent: { service: "proxy", code: "ssrf_blocked", error: e.message },
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
throw e;
|
|
267
|
+
}
|
|
268
|
+
const { offload_large, ...upstreamBody } = input;
|
|
269
|
+
const res = await request(PROXY_API_URL, {
|
|
270
|
+
method: "POST",
|
|
271
|
+
headers: {
|
|
272
|
+
"X-API-Key": getApiKey(),
|
|
273
|
+
"Content-Type": "application/json",
|
|
274
|
+
"User-Agent": "foura-mcp/0.2.11 (proxy)",
|
|
275
|
+
},
|
|
276
|
+
body: JSON.stringify(upstreamBody),
|
|
277
|
+
});
|
|
278
|
+
const text = await res.body.text();
|
|
279
|
+
let parsed;
|
|
280
|
+
try {
|
|
281
|
+
parsed = JSON.parse(text);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return {
|
|
285
|
+
isError: true,
|
|
286
|
+
content: [
|
|
287
|
+
{
|
|
288
|
+
type: "text",
|
|
289
|
+
text: `FourA proxy — non-JSON response (${res.statusCode}): ${text.slice(0, 200)}`,
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
structuredContent: {
|
|
293
|
+
service: "proxy",
|
|
294
|
+
code: "upstream_non_json",
|
|
295
|
+
status: res.statusCode,
|
|
296
|
+
error: `Upstream returned non-JSON (${res.statusCode}): ${text.slice(0, 200)}`,
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
301
|
+
const e = parsed;
|
|
302
|
+
const errMsg = typeof e.error === "string" ? e.error : "Unknown";
|
|
303
|
+
const retryStr = typeof e.retryAfter === "number" ? ` · retry ${e.retryAfter}s` : "";
|
|
304
|
+
return {
|
|
305
|
+
isError: true,
|
|
306
|
+
content: [{ type: "text", text: `FourA proxy error ${res.statusCode}: ${errMsg}${retryStr}` }],
|
|
307
|
+
structuredContent: {
|
|
308
|
+
...e,
|
|
309
|
+
service: "proxy",
|
|
310
|
+
code: deriveCode(res.statusCode, e),
|
|
311
|
+
status: typeof e.status === "number" ? e.status : res.statusCode,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const parsedObj = parsed;
|
|
316
|
+
// Bug 8 fix — all-proxies-fail returns HTTP 200 + PrResponseError shape
|
|
317
|
+
// {error, request, total}. dwstack proxy/src/api/request.ts:43
|
|
318
|
+
// forwards without overriding the response status. Without this check,
|
|
319
|
+
// foura-mcp would silently return "success" with a missing-data body.
|
|
320
|
+
if (typeof parsedObj.error === "string" && parsedObj.error.length > 0) {
|
|
321
|
+
const innerStatus = typeof parsedObj.status === "number" ? parsedObj.status : 0;
|
|
322
|
+
return {
|
|
323
|
+
isError: true,
|
|
324
|
+
content: [
|
|
325
|
+
{
|
|
326
|
+
type: "text",
|
|
327
|
+
text: `FourA proxy — all attempts failed: ${parsedObj.error}`,
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
structuredContent: {
|
|
331
|
+
...parsedObj,
|
|
332
|
+
service: "proxy",
|
|
333
|
+
code: innerStatus > 0
|
|
334
|
+
? deriveCode(innerStatus, parsedObj)
|
|
335
|
+
: "upstream_error",
|
|
336
|
+
status: innerStatus,
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const data = parsedObj.data;
|
|
341
|
+
let bodyStr = null;
|
|
342
|
+
if (typeof data === "string")
|
|
343
|
+
bodyStr = data;
|
|
344
|
+
else if (data && typeof data === "object")
|
|
345
|
+
bodyStr = JSON.stringify(data);
|
|
346
|
+
const statusLabel = parsedObj.status ?? "?";
|
|
347
|
+
const proxyLabel = parsedObj.proxy ? ` · via ${parsedObj.proxy}` : "";
|
|
348
|
+
const shouldOffload = offload_large === true
|
|
349
|
+
&& bodyStr
|
|
350
|
+
&& Buffer.byteLength(bodyStr, "utf8") >= THRESHOLD_BYTES;
|
|
351
|
+
if (shouldOffload && bodyStr) {
|
|
352
|
+
const ct = extractContentTypeFromHeaderInfo(parsedObj.headers) ?? "text/plain";
|
|
353
|
+
const stored = await storePayload(bodyStr, ct, "response-body");
|
|
354
|
+
const sizeKb = (stored.size / 1024).toFixed(1);
|
|
355
|
+
return {
|
|
356
|
+
content: [
|
|
357
|
+
{ type: "text", text: `${statusLabel} · offloaded ${sizeKb} KB${proxyLabel}` },
|
|
358
|
+
{ type: "resource_link", uri: stored.uri, name: stored.name, mimeType: stored.mimeType },
|
|
359
|
+
],
|
|
360
|
+
structuredContent: {
|
|
361
|
+
status: parsedObj.status,
|
|
362
|
+
headers: parsedObj.headers,
|
|
363
|
+
total_time: parsedObj.total_time,
|
|
364
|
+
proxy: parsedObj.proxy,
|
|
365
|
+
total: parsedObj.total,
|
|
366
|
+
offloaded_resource_uri: stored.uri,
|
|
367
|
+
size_bytes: stored.size,
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
const sizeKb = bodyStr ? (Buffer.byteLength(bodyStr, "utf8") / 1024).toFixed(1) : "0";
|
|
372
|
+
return {
|
|
373
|
+
content: [{ type: "text", text: `${statusLabel} OK · ${sizeKb} KB${proxyLabel}` }],
|
|
374
|
+
structuredContent: parsedObj,
|
|
375
|
+
};
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
export const __test = { deriveCode, ProxyHeaderInfoSchema, ProxyInnerRequestSchema, proxyInputShape, proxyOutputShape };
|
|
379
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/tools/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,SAAS,gCAAgC,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J,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,UAAU,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
declare function deriveCode(status: number, envelope: Record<string, unknown>): string;
|
|
4
|
+
declare function guardHandler(service: "single" | "proxy" | "browser", outputSchema: z.ZodObject<any>, fn: () => Promise<any>): Promise<any>;
|
|
5
|
+
export declare function registerSingleTool(server: McpServer): void;
|
|
6
|
+
export declare const __test: {
|
|
7
|
+
deriveCode: typeof deriveCode;
|
|
8
|
+
HeaderInfoSchema: z.ZodObject<{
|
|
9
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
version: z.ZodOptional<z.ZodString>;
|
|
11
|
+
code: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
15
|
+
singleInputShape: {
|
|
16
|
+
method: z.ZodString;
|
|
17
|
+
url: z.ZodString;
|
|
18
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>>;
|
|
19
|
+
unblocker: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
data: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
21
|
+
proxy: z.ZodOptional<z.ZodString>;
|
|
22
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
connect_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
accept_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
server_response_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
dns_cache_timeout_sec: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
followRedirects: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
tryJsonData: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
returnBuffer: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
validate: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
status: z.ZodOptional<z.ZodObject<{
|
|
32
|
+
accept: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
33
|
+
fail: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
headers: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
accept: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
37
|
+
fail: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
fail: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
offload_large: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
};
|
|
46
|
+
singleOutputShape: {
|
|
47
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
headers: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
49
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
version: z.ZodOptional<z.ZodString>;
|
|
51
|
+
code: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>>, z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
55
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
56
|
+
total_time: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
|
|
57
|
+
offloaded_resource_uri: z.ZodOptional<z.ZodString>;
|
|
58
|
+
size_bytes: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
error: z.ZodOptional<z.ZodString>;
|
|
60
|
+
service: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
single: "single";
|
|
62
|
+
proxy: "proxy";
|
|
63
|
+
browser: "browser";
|
|
64
|
+
api: "api";
|
|
65
|
+
}>>;
|
|
66
|
+
retryAfter: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
current: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
concurrency: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
rpm: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
maxConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
maxRpm: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
code: z.ZodOptional<z.ZodString>;
|
|
76
|
+
};
|
|
77
|
+
guardHandler: typeof guardHandler;
|
|
78
|
+
};
|
|
79
|
+
export {};
|