Skip to content

Commit 2a7f509

Browse files
committed
feat(mcp): add RFC 9728 protected-resource metadata endpoint
1 parent a2c3d14 commit 2a7f509

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

  • apps/dashboard/server/routes/.well-known/oauth-protected-resource/api
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
})

0 commit comments

Comments
 (0)