Skip to main content
Glama

fetch_url

Fetch content from any web URL to extract text and data for analysis, processing, or integration with other tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
maxBytesNo

Implementation Reference

  • Handler function that fetches the URL content using undici fetch, respects maxBytes limit by reading stream in chunks, extracts content-type and body as text, returns structured content with summary and body.
    async (input) => { const maxBytes = Math.min(input.maxBytes ?? MAX_FETCH_BYTES, 16 * 1024 * 1024); const res = await fetch(input.url, { headers: { "User-Agent": "Mozilla/5.0 (compatible; MCP-Web-Tools/0.1; +https://example.com)", Accept: "*/*", }, }); const contentType = res.headers.get("content-type") || ""; const reader = res.body.getReader(); let received = 0; const chunks = []; while (true) { const { done, value } = await reader.read(); if (done) break; received += value.byteLength; if (received > maxBytes) { chunks.push(value.subarray(0, value.byteLength - (received - maxBytes))); break; } chunks.push(value); } const body = Buffer.concat(chunks.map((u) => Buffer.from(u))).toString("utf8"); const summary = `contentType: ${contentType}\nbytes: ${Math.min(received, maxBytes)}`; return { content: [ { type: "text", text: summary }, { type: "text", text: body }, ], }; }
  • Input schema using Zod: requires a valid URL, optional maxBytes between 1KB and 16MB.
    { url: z.string().url(), maxBytes: z.number().int().min(1024).max(16 * 1024 * 1024).optional(), },
  • src/server.js:95-96 (registration)
    Tool registration call: server.tool("fetch_url", schema, handler) registering the fetch_url tool with MCP server.
    server.tool( "fetch_url",

Other Tools

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/JoaoPedroLanca/mcp-web-tools'

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