@@ -5,7 +5,7 @@ import { authorizationHandler, AuthorizationHandlerOptions } from "./handlers/au
55import { revocationHandler , RevocationHandlerOptions } from "./handlers/revoke.js" ;
66import { metadataHandler } from "./handlers/metadata.js" ;
77import { OAuthServerProvider } from "./provider.js" ;
8- import { OAuthProtectedResourceMetadata } from "../../shared/auth.js" ;
8+ import { OAuthMetadata , OAuthProtectedResourceMetadata } from "../../shared/auth.js" ;
99
1010export type AuthRouterOptions = {
1111 /**
@@ -30,12 +30,17 @@ export type AuthRouterOptions = {
3030 */
3131 serviceDocumentationUrl ?: URL ;
3232
33+ /**
34+ * An optional list of scopes supported by this authorization server
35+ */
36+ scopesSupported ?: string [ ] ;
37+
3338 // Individual options per route
3439 authorizationOptions ?: Omit < AuthorizationHandlerOptions , "provider" > ;
3540 clientRegistrationOptions ?: Omit < ClientRegistrationHandlerOptions , "clientsStore" > ;
3641 revocationOptions ?: Omit < RevocationHandlerOptions , "provider" > ;
3742 tokenOptions ?: Omit < TokenHandlerOptions , "provider" > ;
38- protectedResourceOptions ?: Omit < ProtectedResourceRouterOptions , "issuerUrl" | "serviceDocumentationUrl" > ;
43+ protectedResourceOptions ?: Omit < ProtectedResourceRouterOptions , "issuerUrl" | "serviceDocumentationUrl" | "scopesSupported" > ;
3944} ;
4045
4146const checkIssuerUrl = ( issuer : URL ) : void => {
@@ -72,7 +77,7 @@ export function mcpAuthRouter(options: AuthRouterOptions): RequestHandler {
7277 const registration_endpoint = options . provider . clientsStore . registerClient ? "/register" : undefined ;
7378 const revocation_endpoint = options . provider . revokeToken ? "/revoke" : undefined ;
7479
75- const metadata = {
80+ const metadata : OAuthMetadata = {
7681 issuer : issuer . href ,
7782 service_documentation : options . serviceDocumentationUrl ?. href ,
7883
@@ -84,6 +89,8 @@ export function mcpAuthRouter(options: AuthRouterOptions): RequestHandler {
8489 token_endpoint_auth_methods_supported : [ "client_secret_post" ] ,
8590 grant_types_supported : [ "authorization_code" , "refresh_token" ] ,
8691
92+ scopes_supported : options . scopesSupported ,
93+
8794 revocation_endpoint : revocation_endpoint ? new URL ( revocation_endpoint , baseUrl || issuer ) . href : undefined ,
8895 revocation_endpoint_auth_methods_supported : revocation_endpoint ? [ "client_secret_post" ] : undefined ,
8996
@@ -113,6 +120,7 @@ export function mcpAuthRouter(options: AuthRouterOptions): RequestHandler {
113120 router . use ( mcpProtectedResourceRouter ( {
114121 issuerUrl : issuer ,
115122 serviceDocumentationUrl : options . serviceDocumentationUrl ,
123+ scopesSupported : options . scopesSupported ,
116124 ...defaultProtectedResourceOptions ,
117125 ...options . protectedResourceOptions
118126 } ) )
0 commit comments