fix(mcp): cap transport response bodies to bound a hostile tools/call payload#5850
Conversation
… payload A full-lifecycle comparison against LibreChat found the one place a reference client was stricter: the live transport had no response-body byte cap, so a hostile server could stream an unbounded tools/call result and OOM the process (discovery and OAuth bodies were already capped). Cap non-GET response bodies at 16 MiB — counted as they stream, not buffered — while leaving the standalone GET SSE notification stream uncapped (a cumulative cap would break its long-lived nature). Mirrors LibreChat's transport response-size cap.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview GET requests (the long-lived standalone SSE notification stream) stay uncapped so legitimate sessions are not cut off. The same wrapping applies to Tests cover oversized POST vs uncapped GET, and metadata fields on capped responses. Reviewed by Cursor Bugbot for commit b4cd142. Configure here. |
Greptile SummaryThis PR limits MCP transport response bodies to reduce memory exhaustion risk. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "fix(mcp): drop stale framing headers on ..." | Re-trigger Greptile |
|
@cursor review |
new Response() resets url/redirected; the SDK resolves relative auth-metadata URLs (resource_metadata) against response.url, so carry the originals over via defineProperty on the wrapped response.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 554376d. Configure here.
The wrapped body is the already-decoded stream, so content-encoding/content-length would misdescribe it — strip them, matching bufferUnderDeadline.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b4cd142. Configure here.
Summary
Closes the one gap a full-lifecycle comparison against OpenCode / LibreChat / Claude Code / VS Code surfaced — the single place a reference client (LibreChat) was stricter than us.
tools/callresult and OOM the process. We already cap discovery (5 MiB) and OAuth (1 MiB) bodies, but not arbitrary tool-result bodies.tools/call,initialize) where a bounded body is correct.With this, every one of the 14 MCP lifecycle stages is at or above state-of-the-art reference-client practice.
Type of Change
Testing
Checklist