Skip to content

Fix large MCP streamable HTTP payloads#1434

Draft
threepointone wants to merge 1 commit intomainfrom
fix/mcp-large-streamable-http-payloads
Draft

Fix large MCP streamable HTTP payloads#1434
threepointone wants to merge 1 commit intomainfrom
fix/mcp-large-streamable-http-payloads

Conversation

@threepointone
Copy link
Copy Markdown
Contributor

@threepointone threepointone commented Apr 30, 2026

Summary

Why

The reported TLS Alert: record_overflow failure was caused by large MCP JSON-RPC payloads being base64-encoded into cf-mcp-message during the internal Worker-to-Durable Object WebSocket upgrade. That made the request body part of an HTTP header, where it could exceed Cloudflare's per-header limit before the Durable Object ever saw the request.

A direct HTTP forwarding path would avoid the header limit too, but it changes the lifecycle story for streamable HTTP: the current bridge uses WebSockets specifically so idle/long-lived streams can hibernate with the Durable Object runtime. This PR keeps that architecture and only moves the large data out of headers and into the WebSocket data channel, which is the smaller behavioral change for a published package bug fix.

Details

  • cf-mcp-method remains as the small internal routing signal for POST vs GET upgrade requests.
  • cf-mcp-message is no longer populated with the serialized payload and is stripped from forwarded request metadata.
  • POST bridge state is recorded on connect, and the first WebSocket message is parsed as the JSON-RPC body.
  • Notification/result/error-only POSTs still return 202; the internal bridge is closed after the DO receives and processes the frame.

Test plan

  • npm run test:workers -- src/tests/mcp/transports/streamable-http.test.ts
  • npm run typecheck
  • npm run check

Made with Cursor


Open in Devin Review

Send internal streamable HTTP payloads over the WebSocket data channel so large JSON-RPC requests avoid Worker header limits while preserving Durable Object hibernation behavior.

Made-with: Cursor
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 37d3813

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 30, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1434

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1434

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1434

hono-agents

npm i https://pkg.pr.new/hono-agents@1434

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1434

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1434

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1434

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1434

commit: 37d3813

@threepointone
Copy link
Copy Markdown
Contributor Author

putting into draft till we get a repro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP streamable-HTTP transport: large JSON-RPC payloads (>16 KB) fail with TLS record_overflow due to header-encoding

1 participant