Skip to content

Commit 2270239

Browse files
committed
thread throughs scopes
1 parent 055d95d commit 2270239

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/examples/server/simpleStreamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ if (useOAuth) {
182182
provider,
183183
issuerUrl,
184184
baseUrl: issuerUrl,
185+
scopesSupported: ['mcp:tools'],
185186
protectedResourceOptions: {
186187
serverUrl,
187188
resourceName: 'MCP Demo Server',
188-
scopesSupported: ['mcp:tools'],
189189
},
190190
}));
191191

src/server/auth/router.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { authorizationHandler, AuthorizationHandlerOptions } from "./handlers/au
55
import { revocationHandler, RevocationHandlerOptions } from "./handlers/revoke.js";
66
import { metadataHandler } from "./handlers/metadata.js";
77
import { OAuthServerProvider } from "./provider.js";
8-
import { OAuthProtectedResourceMetadata } from "../../shared/auth.js";
8+
import { OAuthMetadata, OAuthProtectedResourceMetadata } from "../../shared/auth.js";
99

1010
export 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

4146
const 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

Comments
 (0)