Repository navigation
feat(agents): support workers-oauth-provider 1.x - #2680
Open
mattzcarey wants to merge 2 commits into
Open
mattzcarey wants to merge 2 commits into
mattzcarey wants to merge 2 commits into
Conversation
createMcpHandler maps the verified token that workers-oauth-provider 1.x sets as ctx.auth to SDK v2 AuthInfo, so context.http.authInfo works behind OAuthProvider and OAuthResourceServer. The authenticated MCP example moves to @cloudflare/workers-oauth-provider ^1.2.4 and sets resourceMetadata.resource from an MCP_RESOURCE var. Securing MCP Servers now explains the library's consent and upstream sign-in helpers instead of hand-rolled CSRF and state code.
🦋 Changeset detectedLatest commit: b0ea890 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 |
Contributor
|
✅ agents import sizes: no significant changes ( |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
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.
createMcpHandlernow works with@cloudflare/workers-oauth-provider1.x: tool callbacks getcontext.http.authInfo(token, client ID, scopes, expiry, resource) behind bothOAuthProviderandOAuthResourceServer. The authenticated MCP example moves to 1.2.4, and the security doc explains the library's consent and sign-in APIs.ctx.auth. The handler only read averified-context.v1symbol, which no provider release ever set, soauthInfowas always empty and onlygetMcpAuthContext().propsworked. Provider 1.x puts the verified token on the execution context asctx.auth.src/mcp/server/auth-context.tsnow maps that to SDK v2AuthInfowhen the symbol is absent. Actx.authwithout a client ID, or in the wrong shape, is ignored, and props still flow as before.examples/mcp-worker-authenticated. Bumped to^1.2.4and kept the single-WorkerOAuthProvider. 1.x requiresresourceMetadata.resource, the URL every token is bound to, so the example reads it from anMCP_RESOURCEvar, ascloudflare-mcpdoes. The default is thevite devURL.Docs.
securing-mcp-servers.mdreplaces the hand-rolled CSRF, state and approved-client cookie code with the library'sdescribeConsent/beginConsent/approveConsent/denyConsent/isConsentRememberedandbeginUpstream/finishUpstreamhelpers, plusinsufficientScope()for step-up.mcp-servers.mdaddsresourceMetadatato itsOAuthProvidersnippet.New tests in
handler-stateless.test.tscoverctx.authmapping and the no-client-ID fallback. Workers MCP tests ran.Ran the example with
vite dev:/mcpreturns 401 pointing athttp://localhost:5173/.well-known/oauth-protected-resource/mcp, which reports the configured resource.