|
| 1 | +import { NextRequest, NextResponse } from 'next/server'; |
| 2 | + |
| 3 | +/** |
| 4 | + * RFC 9728 OAuth Authorization Server Metadata |
| 5 | + * Rewritten from /.well-known/oauth-authorization-server/api/mcp |
| 6 | + */ |
| 7 | +export async function GET(request: NextRequest) { |
| 8 | + const proto = request.headers.get('x-forwarded-proto') || 'https'; |
| 9 | + const host = request.headers.get('host') || 'localhost:3000'; |
| 10 | + const origin = `${proto}://${host}`; |
| 11 | + const mcpBase = `${origin}/api/mcp`; |
| 12 | + |
| 13 | + return NextResponse.json({ |
| 14 | + issuer: mcpBase, |
| 15 | + authorization_endpoint: `${mcpBase}/auth/authorize`, |
| 16 | + token_endpoint: `${mcpBase}/auth/token`, |
| 17 | + registration_endpoint: `${mcpBase}/auth/register`, |
| 18 | + response_types_supported: ['code'], |
| 19 | + grant_types_supported: ['authorization_code', 'refresh_token'], |
| 20 | + token_endpoint_auth_methods_supported: ['none', 'client_secret_post'], |
| 21 | + code_challenge_methods_supported: ['S256'], |
| 22 | + scopes_supported: ['mcp:tools'], |
| 23 | + revocation_endpoint: `${mcpBase}/auth/revoke`, |
| 24 | + }, { |
| 25 | + headers: { |
| 26 | + 'cache-control': 'public, max-age=3600', |
| 27 | + 'access-control-allow-origin': '*', |
| 28 | + }, |
| 29 | + }); |
| 30 | +} |
0 commit comments