You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
advertise Clerk as the first authorization server for ordinary OAuth
keep Context7 as a separate authorization server for enterprise-managed id-jag
stop coupling the interactive OAuth issuer to the enterprise token issuer
add integration coverage for the protected-resource metadata order
document the independent user-OAuth and enterprise issuer environment variables
Root cause
The MCP protected-resource metadata advertised https://context7.com, while the actual authorization response is produced by Clerk with iss=https://clerk.context7.com. RFC 9207-aware clients correctly reject that response because the discovered and returned issuers differ.
Clerk is now advertised directly for authorization-code flows, making discovery metadata and the final response use the same issuer. Context7 remains listed for its independent enterprise id-jag exchange.
No Clerk proxy URL or primary-domain change is required.
Compatibility
existing Context7 token and registration compatibility endpoints remain available
existing access and refresh tokens are not invalidated
clients that cached Context7 as the issuer and need to authorize again must clear/recreate that local OAuth registration so they rediscover Clerk; migrating Clerk records cannot change a client's cached issuer
Approved. The change is correct: validateJWT already accepted Clerk-issued tokens (packages/mcp/src/lib/jwt.ts), so only discovery was wrong. The integration test uses getDefaultEnvironment(), which removes stray env vars, so the assertion stays stable.
Nitpicks only, none of them blocking:
1. .env.example is now incomplete
Line 7 still lists only AUTH_SERVER_URL. Add OAUTH_AUTH_SERVER_URL and EMA_ISSUER so a new developer sees the two independent knobs.
2. Local development behavior changes quietly
A developer who keeps AUTH_SERVER_URL=http://localhost:3000 now gets EMA on localhost, but user OAuth on production Clerk. Before this PR, both used localhost. Please record this in the EMA_ISSUER comment in constants.ts.
3. Confirm how id-jag clients select their server
EMA_ISSUER is now the second entry of authorization_servers. An enterprise client must read every entry and select the server that advertises authorization_grant_profiles_supported. If any client uses authorization_servers[0], it will now go to Clerk. Worth one check before step 4 of the rollout.
4. Pre-existing, not caused by this PR
mcp.context7.com/.well-known/oauth-authorization-server proxies Clerk's document. That document contains issuer: https://clerk.context7.com, but the client received it from mcp.context7.com. RFC 8414 section 3.3 lets a strict client refuse it. This is the same class of defect this PR fixes, one layer down. A 308 redirect to Clerk is safer than a proxy, but that can be a separate PR.
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
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
id-jagRoot cause
The MCP protected-resource metadata advertised
https://context7.com, while the actual authorization response is produced by Clerk withiss=https://clerk.context7.com. RFC 9207-aware clients correctly reject that response because the discovered and returned issuers differ.Clerk is now advertised directly for authorization-code flows, making discovery metadata and the final response use the same issuer. Context7 remains listed for its independent enterprise
id-jagexchange.No Clerk proxy URL or primary-domain change is required.
Compatibility
Rollout dependency
Deploy and configure upstash/context7app#963 first:
https://context7.com/oauth/authorizeValidation
pnpm --filter @upstash/context7-mcp typecheckpnpm --filter @upstash/context7-mcp lintpnpm --filter @upstash/context7-mcp test— 77 tests passed