batch_fetch
Fetch multiple URLs simultaneously and convert them to clean Markdown format. Processes up to 10 URLs in parallel, removing ads and unnecessary elements for AI processing.
Instructions
Fetch multiple URLs in parallel and convert them all to clean Markdown. Process up to 10 URLs in a single call.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| urls | Yes | Array of URLs to fetch (1-10) | |
| model | No | AI model ID for cost tracking |
Implementation Reference
- src/index.ts:162-230 (handler)The full handler implementation for the "batch_fetch" MCP tool, including registration, input validation using Zod, API interaction, and response formatting.
server.tool( "batch_fetch", "Fetch multiple URLs in parallel and convert them all to clean Markdown. Process up to 10 URLs in a single call.", { urls: z .array(z.string().url()) .min(1) .max(10) .describe("Array of URLs to fetch (1-10)"), model: z .string() .optional() .describe("AI model ID for cost tracking"), }, async (params) => { const apiKey = getApiKey(); const response = await fetch(`${BASE_URL}/batch`, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ urls: params.urls, model: params.model, }), }); if (!response.ok) { const body = await response.text(); let message: string; try { message = JSON.parse(body).error; } catch { message = body; } throw new Error(`StripFeed API error ${response.status}: ${message}`); } const data = await response.json(); const results = data.results as Array<{ url: string; title: string; markdown: string; tokens: number; originalTokens: number; savingsPercent: number; status: number; error?: string; }>; const sections = results.map((r) => { if (r.status !== 200) { return `## ${r.url}\n\nError: ${r.error ?? `Status ${r.status}`}`; } const saved = `${r.tokens.toLocaleString()} tokens (saved ${r.savingsPercent}% from ${r.originalTokens.toLocaleString()})`; return `## ${r.title || r.url}\n\nSource: ${r.url} | ${saved}\n\n${r.markdown}`; }); const summary = `Fetched ${data.success}/${data.total} URLs successfully.`; return { content: [ { type: "text" as const, text: `${summary}\n\n---\n\n${sections.join("\n\n---\n\n")}` }, ], }; } );