batch_fetch
Fetches up to 10 URLs in parallel and converts each to clean, token-efficient Markdown. Strips ads, navigation, and scripts for AI agents.
Instructions
Fetch multiple URLs in parallel and convert them all to clean Markdown. Process up to 10 URLs in a single call.
Input 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 'batch_fetch' tool handler: calls the /batch endpoint, processes results, and formats markdown output.
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")}` }, ], }; } ); - src/index.ts:162-175 (schema)The input schema for batch_fetch: takes an array of URLs (1-10) and an optional model string.
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"), }, - src/index.ts:162-163 (registration)Registration of the 'batch_fetch' tool on the MCP server via server.tool().
server.tool( "batch_fetch",