File tree Expand file tree Collapse file tree
apps/dashboard/server/routes/.well-known/oauth-protected-resource/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { defineEventHandler , setResponseHeader } from "h3"
2+ import { env } from "../../../../lib/env"
3+
4+ /**
5+ * RFC 9728 OAuth 2.0 Protected Resource Metadata.
6+ *
7+ * Returned to MCP clients that follow the WWW-Authenticate redirect from a
8+ * 401 response on /api/mcp. Tells them which authorization server issues
9+ * tokens for this resource and which scopes are recognized.
10+ *
11+ * URL path mirrors the resource: /api/mcp → /.well-known/oauth-protected-resource/api/mcp
12+ */
13+ export default defineEventHandler ( ( event ) => {
14+ if ( ! env . MCP_ENABLED ) {
15+ event . node . res . statusCode = 404
16+ return null
17+ }
18+ setResponseHeader ( event , "Content-Type" , "application/json" )
19+ setResponseHeader ( event , "Cache-Control" , "public, max-age=3600" )
20+ return {
21+ resource : `${ env . BETTER_AUTH_URL } /api/mcp` ,
22+ authorization_servers : [ `${ env . BETTER_AUTH_URL } /api/auth` ] ,
23+ scopes_supported : [ "mcp:full" ] ,
24+ bearer_methods_supported : [ "header" ] ,
25+ resource_documentation : `${ env . BETTER_AUTH_URL } /settings/mcp` ,
26+ }
27+ } )
You can’t perform that action at this time.
0 commit comments