Skip to content

Host cloud MCP sessions on our own DO with the v2 stack - #1608

Closed
RhysSullivan wants to merge 2 commits into
mcp-consolidate-neutralfrom
mcp-consolidate-cloud
Closed

Host cloud MCP sessions on our own DO with the v2 stack#1608
RhysSullivan wants to merge 2 commits into
mcp-consolidate-neutralfrom
mcp-consolidate-cloud

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

The big consolidation step: Cloudflare MCP session serving moves off McpAgent onto our own Durable Object hosting the SDK v2 sessionful stack. patches/[email protected] (911 lines) is deleted and agents is out of every MCP path.

  • The session DO extends DurableObject directly: per-session v2 WebStandardStreamableHTTPServerTransport + the sessionful v2 assembly, direct stub.fetch response streaming (the McpAgent/PartyServer WebSocket bridge and its delivery-ack protocol are gone — stream resumability is the event store's job).
  • do-event-store.ts: DO-storage EventStore carrying the patch's semantics as first-class code — 64 events / 2 MiB per stream, never evict the newest, >120 KiB events deliver live but don't persist, best-effort writes that never break the send path, replay strictly after Last-Event-ID.
  • sse-response-rotation.ts: 30-minute stream rotation with graceful reconnect framing, aligned with the alarm policy.
  • Priming: v2's transport only primes 2025-11-25+ clients (verified in the installed dist); older clients on slow tool calls still need one benign id-bearing event before the result, ported minimally as our code. e2e/cloud/mcp-priming-reconnect.test.ts is the CI arbiter.
  • Native elicitation flows through the SDK legacy shim like the neutral hosts; model/browser pause-resume, approval leases, cross-DO model resume, and the alarm policy keep their semantics (alarm arming is now fully ours).
  • Session addressing keeps DO-unique-id session ids (idFromString); class names and wrangler bindings unchanged, so no DO migrations. Deliberate cutover behavior: sessions created before this deploy get one clean 404 and clients re-initialize transparently — no storage-compat restore of agents-internal state.
  • Patch-internal test suites rewritten as behavior-equivalent tests of our components; a real v1-SDK client drives the DO-hosted stack end to end incl. reconnect-mid-call replay.

Tests: 57 hosts/cloudflare + 204 hosts/mcp + 24 host-cloudflare + 244 cloud (3 known-environmental failures pre-exist on parent). Key acceptance signal is CI's cloud e2e: priming reconnect, SSE replay, oversize response, session survival.

Stacked on #1606. Next PR deletes the v1 assembly and the V2 naming.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing d62e666 Commit Preview URL

Branch Preview URL
Aug 16 2026, 03:59 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud d62e666 Aug 16 2026, 04:00 PM

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1608

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1608

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1608

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1608

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1608

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1608

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1608

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1608

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1608

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1608

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1608

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1608

executor

npm i https://pkg.pr.new/executor@1608

commit: d62e666

@RhysSullivan

Copy link
Copy Markdown
Collaborator Author

CI verdict: 3 cloud e2e shards red — the acceptance gate working as intended. Four distinct failures:

  1. mcp-client-sessions (unknown session id must fail fast): likely idFromString throwing on arbitrary client-supplied session strings where the old path returned a clean 404. Needs a parse guard in the worker.
  2. mcp-sse-replay (severed POST response replays on the next standalone GET): the patch replayed stranded POST-stream events onto the GET stream; the stock v2 eventStore only resumes the same stream via Last-Event-ID. The DO needs the cross-stream undelivered-response replay ported.
  3. mcp-priming-reconnect (stock old client recovers a mid-call result): the minimal priming port is not effective under real workerd — re-verify against the severed-stream flow.
  4. repro-transport-brick (concurrent GET+POST after idle-dispose): restore/dispose race in the new lifecycle.

Iterating with the narrow e2e scenarios locally; will push the fix commit to this branch.

@RhysSullivan

Copy link
Copy Markdown
Collaborator Author

Folded into #1611 (single consolidated PR per review preference).

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.

1 participant