Repository navigation
feat(mcp demos): move every McpAgent demo to createMcpHandler - #680
Merged
Merged
Conversation
Rewrite the remaining McpAgent demos as stateless createMcpHandler servers on MCP SDK v2 (@modelcontextprotocol/server 2.3.1, agents ^0.29.0). Props come from getMcpAuthContext(), bindings from cloudflare:workers, and the MCP Durable Object bindings and migrations are removed. READMEs point at /mcp and Streamable HTTP instead of /sse.
|
commit: |
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.
Every MCP demo in this repo except the Descope one now runs a stateless
createMcpHandlerserver on MCP SDK v2 instead ofMcpAgent.McpAgenthas been deprecated sinceagents@0.20.0, and these demos are the starters thatcreate-cloudflareand the Agents docs point people at.Each demo now:
McpServerin acreateServer()factory withregisterTool/registerResource, served bycreateMcpHandlerfromagents/mcp/servergetMcpAuthContext()(inside the factory, so tools can still depend on who is signed in) and bindings withenvfromcloudflare:workersMCP_OBJECTDurable Object binding and migration fromwrangler.jsoncandworker-configuration.d.tsagents@^0.29.0and@modelcontextprotocol/server@2.3.1instead of@modelcontextprotocol/sdkThe OAuth demos also move to
@cloudflare/workers-oauth-provider@^1.2.4, still using the single-WorkerOAuthProvider. 1.x requiresresourceMetadata.resource, the URL every token is bound to, so each demo reads it from anMCP_RESOURCEvar (ascloudflare-mcpdoes). The default is the local dev URL, and each README says to set it to the deployed URL. The removedallowPlainPKCEoption is dropped.Demos that verify the caller themselves (
mcp-server-bearer-auth,remote-mcp-cf-access-self-hosted) pass the identity withcreateMcpHandler(createServer, { authContext: { props } }). The Stytch demos keep their Hono middleware, which setsctx.props. READMEs now say/mcpand Streamable HTTP instead of/sse; none of these servers served SSE.The first commit is @harshil1712's #633 (
remote-mcp-cf-access,remote-mcp-github-oauth), cherry-picked with authorship, so this supersedes it.remote-mcp-server-descope-authis left to #646 / #669.tsc --noEmitandwrangler deploy --dry-runpass for every changed demo, andvite buildfor the two Stytch demos.remote-mcp-serverunderwrangler devthrough the full OAuth flow (registration,/authorize, token, authorizedtools/call) on 1.2.4.mcp-server-bearer-authunderwrangler dev:/mcpreturns 401 without a token, andgetTokenreturns the bearer token throughgetMcpAuthContext().