feat(mcp): add SDK v2 client and stateless server support#1557
Open
mattzcarey wants to merge 13 commits into
Open
feat(mcp): add SDK v2 client and stateless server support#1557mattzcarey wants to merge 13 commits into
mattzcarey wants to merge 13 commits into
Conversation
🦋 Changeset detectedLatest commit: c38957c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
6 tasks
mattzcarey
force-pushed
the
chore/mcp-sdk-v2-upgrade
branch
from
July 7, 2026 12:51
bbb79a9 to
384c432
Compare
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
mattzcarey
marked this pull request as ready for review
July 7, 2026 13:03
mattzcarey
force-pushed
the
chore/mcp-sdk-v2-upgrade
branch
from
July 14, 2026 10:57
42ce495 to
8059e94
Compare
mattzcarey
force-pushed
the
chore/mcp-sdk-v2-upgrade
branch
2 times, most recently
from
July 14, 2026 18:15
c86cbec to
80a8fbd
Compare
3 tasks
mattzcarey
force-pushed
the
chore/mcp-sdk-v2-upgrade
branch
from
July 20, 2026 18:13
d163561 to
36971d9
Compare
The SDK v2 handler intentionally leaves deployment validation to its host, but the Agents Worker wrapper previously delegated present Origin headers without a guard. Validate them against localhost-class hostnames by default, expose an explicit browser-host allowlist, and keep Origin-less non-browser clients working. Also allow the modern Mcp-Method and Mcp-Name headers in default CORS preflights and remove the now-clean v2 conformance baselines.
mattzcarey
force-pushed
the
chore/mcp-sdk-v2-upgrade
branch
from
July 22, 2026 15:19
6be2cac to
c38957c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrade the Agents MCP stack to the split MCP SDK v2 packages while retaining the existing SDK v1 server and Legacy protocol paths.
Stateless server
agents/mcp/serverentry for the Agents Worker wrapper;@modelcontextprotocol/server@2.0.0-beta.5;McpServerowned by the upstream SDK rather than re-exporting it;McpAgent,WorkerTransport, MCP client transports, PartyServer, and SDK v1 from the Stateless bundle;legacy: "reject"for a Stateless-only endpoint;WorkerTransport;allowedOriginHostnames: "*"when trusted upstream middleware performs validation;fetch,close,notify, andbuscontrols.The compatibility
agents/mcpentry remains available. Its implementation is now separated into explicit compatibility and Legacy modules.createLegacyMcpHandlerandWorkerTransportremain supported.McpAgentremains deprecated and feature-frozen.Client
@modelcontextprotocol/client@2.0.0-beta.5;callTool,getPrompt, andreadResourcepending while input is collected;agents/mcp/client;priorshape for safe HTTP restoration.OAuth and integrations
skipIssuerMetadataValidationcompatibility option for trusted Legacy metadata;@cloudflare/codemodean optional peer, with direct dependencies added to every workspace consumer.Elicitation examples
examples/mcp-elicitation-mrtr: Stateless Elicitation, including a two-round tool flow;examples/mcp-elicitation: Legacy Elicitation, retaining Durable Object state,WorkerTransport, pushed form/URL requests, and SSE replay.Structure and coverage
agents/mcp/server;design/mcp.md;Lifecycle boundary
In-flight Stateless Elicitation remains memory-only. Durable Object hibernation, isolate restart, transport loss, or connection reconstruction rejects the active operation. This PR does not persist
requestStateor add a manual continuation API.Verification
pnpm install --frozen-lockfilepnpm run buildpnpm run check— exports, formatting, lint, and all 118 TypeScript projectspnpm --filter agents run test— 125 files / 2,345 tests@modelcontextprotocol/conformance@0.2.0-alpha.9McpAgent: 29 clean / 3 documented failures eachFixes #1848.