Skip to main content
Glama

fetch_url

Fetch and return content from any web URL, with optional size limits, to access web page data for analysis or processing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
maxBytesNo

Implementation Reference

  • Handler function for 'fetch_url' tool: Fetches the given URL, respects maxBytes limit, streams and truncates body if necessary, returns content-type summary and body text.
    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 for 'fetch_url' tool 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)
    Registration of the 'fetch_url' tool using McpServer.tool() with inline schema and handler.
    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