Skip to main content
Glama

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
NameRequiredDescriptionDefault
urlYesURL to fetch

Implementation Reference

  • 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}` }] };
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ElromEvedElElyon/claw-mcp-toolkit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server