modelcontextprotocol/servers · error · Error
Response from ${url} exceeds ${maxBytes} bytes
Error message
Response from ${url} exceeds ${maxBytes} bytes What it means
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.
Source
Thrown at src/everything/tools/gzip-file-as-resource.ts:227
}
}
// Read the fetched data from the response body
const reader = response.body.getReader();
const chunks = [];
let totalSize = 0;
// Read chunks until done
try {
while (true) {
const { done, value } = await reader.read();
if (done) break;
totalSize += value.length;
if (totalSize > maxBytes) {
reader.cancel();
throw new Error(`Response from ${url} exceeds ${maxBytes} bytes`);
}
chunks.push(value);
}
} finally {
reader.releaseLock();
}
// Combine chunks into a single buffer
const buffer = new Uint8Array(totalSize);
let offset = 0;
for (const chunk of chunks) {
buffer.set(chunk, offset);
offset += chunk.length;
}
return buffer.buffer;
} finally {View on GitHub (pinned to 76d64c822f)
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.
Example fix
# before: default 10MB cap, chunked stream sends 15MB # after GZIP_MAX_FETCH_SIZE=20000000 node ...
Defensive patterns
Strategy: validation
Validate before calling
const MAX = Number(process.env.GZIP_MAX_FETCH_SIZE ?? 10*1024*1024);
// stream-resolve the true size before calling the tool when Content-Length is absent
async function trueSize(url: string): Promise<number> {
const r = await fetch(url); let total = 0;
for await (const chunk of r.body!) { total += chunk.length; if (total > MAX) break; }
return total;
} Try / catch
try {
await callGzipTool({ data: url });
} catch (e) {
if (e instanceof Error && e.message.includes('exceeds')) {
// file larger than cap (or under-reported Content-Length)
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Content-Length for ${url} exceeds max of ${maxBytes}: ${cont
- Domain ${domain} is not in the allowed domains list.
- Unsupported URL protocol for ${dataUri}. Only http, https, a
- Error processing file ${dataUri}: ${error instanceof Error ?
- No response body
AI-assisted analysis of modelcontextprotocol/servers@76d64c822f (2026-08-12).
Data as JSON: /api/errors/96c4aac089ec4d08.
Report an issue: GitHub.