web_fetch
Fetch URL content and convert HTML to readable text for data extraction and analysis.
Instructions
Fetch a URL and return its content as text (HTML stripped to readable text)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to fetch |
Implementation Reference
- src/modules/web.ts:7-18 (handler)Implementation of the "web_fetch" tool handler, which fetches content, strips HTML tags/scripts/styles, and returns the cleaned text.
server.tool("web_fetch", "Fetch a URL and return its content as text (HTML stripped to readable text)", { url: z.string().url().describe("URL to fetch") }, async ({ url }) => { const html = await safeFetchText(url); const text = html.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "") .replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "") .replace(/<[^>]+>/g, " ") .replace(/\s+/g, " ") .trim() .substring(0, 5000); return { content: [{ type: "text", text: `**Fetched:** ${url}\n\n${text}` }] }; });