Skip to content

Commit 073aaea

Browse files
authored
fix: use scopes_supported in OAuth server metadata (#37)
1 parent 5f01c42 commit 073aaea

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/mcp-auth/src/types/oauth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ const authorizationServerMetadataObject = Object.freeze({
3737
* [[RFC7591](https://www.rfc-editor.org/rfc/rfc7591)].
3838
*/
3939
registration_endpoint: z.string().optional(),
40-
scope_supported: z.array(z.string()).optional(),
40+
/**
41+
* JSON array containing a list of the OAuth 2.0 `scope` values that this authorization server
42+
* supports.
43+
* [[RFC8414](https://datatracker.ietf.org/doc/html/rfc8414#section-2)]
44+
*/
45+
scopes_supported: z.array(z.string()).optional(),
4146
/**
4247
* JSON array containing a list of the OAuth 2.0 `response_type` values that this authorization
4348
* server supports. The array values used are the same as those used with the `response_types`

packages/mcp-auth/src/utils/fetch-server-config.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ describe('fetchServerConfig (OAuth)', () => {
8989
authorization_endpoint: 'https://example.com/oauth/authorize',
9090
token_endpoint: 'https://example.com/oauth/token',
9191
response_types_supported: ['code'],
92+
scopes_supported: ['scope1', 'scope2', 'scope3'],
9293
});
9394

9495
it('should fetch server config using the well-known URL for OAuth', async () => {
@@ -103,6 +104,7 @@ describe('fetchServerConfig (OAuth)', () => {
103104
authorizationEndpoint: 'https://example.com/oauth/authorize',
104105
tokenEndpoint: 'https://example.com/oauth/token',
105106
responseTypesSupported: ['code'],
107+
scopesSupported: ['scope1', 'scope2', 'scope3'],
106108
},
107109
});
108110
expect(wellKnown.isDone()).toBe(true);
@@ -120,6 +122,7 @@ describe('fetchServerConfig (OAuth)', () => {
120122
authorizationEndpoint: 'https://example.com/oauth/authorize',
121123
tokenEndpoint: 'https://example.com/oauth/token',
122124
responseTypesSupported: ['code'],
125+
scopesSupported: ['scope1', 'scope2', 'scope3'],
123126
},
124127
});
125128
expect(wellKnown.isDone()).toBe(true);
@@ -135,6 +138,7 @@ describe('fetchServerConfig (OIDC)', () => {
135138
authorization_endpoint: 'https://example.com/authorize',
136139
token_endpoint: 'https://example.com/token',
137140
response_types_supported: ['code'],
141+
scopes_supported: ['openid', 'profile', 'email'],
138142
});
139143
const config = await fetchServerConfig('https://example.com', { type: 'oidc' });
140144
expect(config).toEqual({
@@ -144,6 +148,7 @@ describe('fetchServerConfig (OIDC)', () => {
144148
authorizationEndpoint: 'https://example.com/authorize',
145149
tokenEndpoint: 'https://example.com/token',
146150
responseTypesSupported: ['code'],
151+
scopesSupported: ['openid', 'profile', 'email'],
147152
},
148153
});
149154
expect(wellKnown.isDone()).toBe(true);

0 commit comments

Comments
 (0)