feat: add OAuth discovery endpoints for ChatGPT MCP compatibility#91
feat: add OAuth discovery endpoints for ChatGPT MCP compatibility#91
Conversation
Add /.well-known/oauth-protected-resource (root-level) and /.well-known/oauth-authorization-server to satisfy RFC 9728 and RFC 8414 discovery requirements expected by ChatGPT's MCP connector. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Risk assessment for this PR: Medium.
Rationale based on the actual diff:
- Adds two new public
/.well-known/*OAuth discovery endpoints in production code. - Changes externally consumed auth metadata (
issuer,authorization_endpoint,token_endpoint, andauthorization_servers) that OAuth clients depend on. - Touches auth-adjacent behavior and interoperability surface area, where regressions can break login/connect flows.
Decision:
- Code review required before merge.
- Not self-approving due to Medium risk and required review.
- Requested reviewer:
@masnwilliams(primary recent contributor/expert in related OAuth route codepaths).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| }, | ||
| }); | ||
|
|
||
| export { handler as GET }; |
There was a problem hiding this comment.
Root protected-resource route duplicates existing mcp route
Low Severity
The new oauth-protected-resource/route.ts is a byte-for-byte duplicate of the existing oauth-protected-resource/mcp/route.ts. Both files share the same handler logic, CORS headers, and metadata construction. Extracting the shared handler into a common module would avoid the risk of the two copies drifting apart when future changes are made to only one of them.




Summary
/.well-known/oauth-protected-resourceroot-level route — ChatGPT strips the/mcppath suffix and checks the base URL, which was returning 404/.well-known/oauth-authorization-serverroute (RFC 8414) — the protected resource metadata declaresauthorization_servers: ["https://mcp.onkernel.com"], so OAuth clients follow that to discover AS capabilities; the missing endpoint caused ChatGPT to report "does not implement OAuth"Context
ChatGPT's MCP connector failed with: "MCP server https://mcp.onkernel.com/ does not implement OAuth"
The existing
/.well-known/oauth-protected-resource/mcproute was correct per RFC 9728 path construction, but ChatGPT also checks the root/.well-known/oauth-protected-resourceand then followsauthorization_serversto discover/.well-known/oauth-authorization-server— both of which were 404ing.Test plan
https://mcp.onkernel.com/.well-known/oauth-protected-resourcereturns JSON (not 404)https://mcp.onkernel.com/.well-known/oauth-authorization-serverreturns JSON withissuer,authorization_endpoint,token_endpoint, etc.https://mcp.onkernel.com/mcpfrom ChatGPT Apps / MCP connector and confirm OAuth flow completes🤖 Generated with Claude Code
Note
Medium Risk
Adds new public
/.well-known/*OAuth discovery endpoints (with permissive CORS) that affect how clients locate auth/token servers; misconfiguration could break OAuth interoperability but does not change core token verification logic.Overview
Adds RFC-style OAuth discovery metadata endpoints to improve MCP client compatibility.
Introduces
/.well-known/oauth-authorization-serverto publish authorization server capabilities (issuer, auth/token endpoints, JWKS, supported grants, and auth methods) derived from the current host plusNEXT_PUBLIC_CLERK_DOMAIN. Also adds a root/.well-known/oauth-protected-resourceendpoint (in addition to the existing/mcpvariant) that proxies Clerk-provided metadata and rewrites it to point clients at this server’s/authorizeand/token, returning CORS-enabled JSON responses for bothGETandOPTIONS.Written by Cursor Bugbot for commit 40a0a2e. This will update automatically on new commits. Configure here.