{"record":{"id":"96c4aac089ec4d08","repo":"modelcontextprotocol/servers","slug":"response-from-url-exceeds-maxbytes-bytes","errorCode":null,"errorMessage":"Response from ${url} exceeds ${maxBytes} bytes","messagePattern":"Response from (.+?) exceeds (.+?) bytes","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/everything/tools/gzip-file-as-resource.ts","lineNumber":227,"sourceCode":"      }\n    }\n\n    // Read the fetched data from the response body\n    const reader = response.body.getReader();\n    const chunks = [];\n    let totalSize = 0;\n\n    // Read chunks until done\n    try {\n      while (true) {\n        const { done, value } = await reader.read();\n        if (done) break;\n\n        totalSize += value.length;\n\n        if (totalSize > maxBytes) {\n          reader.cancel();\n          throw new Error(`Response from ${url} exceeds ${maxBytes} bytes`);\n        }\n\n        chunks.push(value);\n      }\n    } finally {\n      reader.releaseLock();\n    }\n\n    // Combine chunks into a single buffer\n    const buffer = new Uint8Array(totalSize);\n    let offset = 0;\n    for (const chunk of chunks) {\n      buffer.set(chunk, offset);\n      offset += chunk.length;\n    }\n\n    return buffer.buffer;\n  } finally {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/everything/tools/gzip-file-as-resource.ts#L209-L245","documentation":"Thrown by `fetchSafely` during streaming when the cumulative bytes read exceed `GZIP_MAX_FETCH_SIZE`, even if Content-Length was absent or under-reported. The reader is cancelled before throwing. This is the authoritative size guard; Content-Length (error 11) is only an early hint.","triggerScenarios":"A server streams more bytes than `maxBytes` in total — either it omitted/lied about Content-Length, or chunked transfer with no length header. Each chunk increments `totalSize`; once it crosses the cap the read loop cancels and throws.","commonSituations":"Downloading a large file from a chunked-transfer endpoint with no Content-Length, a server that under-reports length (malicious or buggy), or a cap that's too low for legitimate use.","solutions":["Fetch a smaller file or compress/split the source first.","Increase `GZIP_MAX_FETCH_SIZE` (bytes) via env to accommodate legitimate large files.","If you control the server, send an accurate Content-Length so the early bail-out (error 11) fires faster and wastes less bandwidth."],"exampleFix":"# before: default 10MB cap, chunked stream sends 15MB\n# after\nGZIP_MAX_FETCH_SIZE=20000000 node ...","handlingStrategy":"validation","validationCode":"const MAX = Number(process.env.GZIP_MAX_FETCH_SIZE ?? 10*1024*1024);\n// stream-resolve the true size before calling the tool when Content-Length is absent\nasync function trueSize(url: string): Promise<number> {\n  const r = await fetch(url); let total = 0;\n  for await (const chunk of r.body!) { total += chunk.length; if (total > MAX) break; }\n  return total;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await callGzipTool({ data: url });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('exceeds')) {\n    // file larger than cap (or under-reported Content-Length)\n  }\n}","preventionTips":["Don't trust Content-Length; this guard catches under-reporting.","Raise GZIP_MAX_FETCH_SIZE for legitimate large files.","If you control the server, send an accurate Content-Length to fail fast."],"tags":["mcp","typescript","everything-server","network","limits","streaming","configuration","env"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}