Skip to content

Commit f7c8c44

Browse files
pcarletonclaude
andauthored
[scenario] authz metadata discovery tests: compatibility with 2025-03-26 spec, prm root, and www-authenticate (#28)
* clean up constructor calls for server lifecycle * add back compat test * fix dup logging, rm prm * avoid fallbacks * better error from example client * add final endpoint method * add test for OASM priority order * s/prepack/prepare/ for npx * try switching to .js * make tsdown version happy default * fix lock * fix prmPath issue * back to main package-lock * fix bin path * Add comprehensive auth scenario test suite - Add index.test.ts to test all auth scenarios with auth-test.ts client - Upgrade @modelcontextprotocol/sdk from 1.20.1 to 1.22.0 - All 5 auth scenarios now pass including auth/basic-metadata-var2 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * consolidate tests into index.test.ts * rename metadata * fix comments * rework auth scenario listing * add 3rd variation of metadata * fix some type issues introduced by version bump * add reusable spec references * more refs * fix up spec references --------- Co-authored-by: Claude <[email protected]>
1 parent 38443d1 commit f7c8c44

20 files changed

+724
-230
lines changed

examples/clients/typescript/helpers/ConformanceOAuthProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export class ConformanceOAuthProvider implements OAuthClientProvider {
6767
throw new Error('No auth code in redirect URL');
6868
}
6969
} else {
70-
throw new Error('No redirect location received');
70+
throw new Error(
71+
`No redirect location received, from '${authorizationUrl.toString()}'`
72+
);
7173
}
7274
} catch (error) {
7375
console.error('Failed to fetch authorization URL:', error);

examples/clients/typescript/helpers/withOAuthRetry.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const handle401 = async (
1414
serverUrl: string | URL
1515
): Promise<void> => {
1616
const resourceMetadataUrl = extractResourceMetadataUrl(response);
17-
1817
let result = await auth(provider, {
1918
serverUrl,
2019
resourceMetadataUrl,

package-lock.json

Lines changed: 107 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"dist"
2727
],
2828
"bin": {
29-
"conformance": "dist/index.mjs"
29+
"conformance": "dist/index.js"
3030
},
3131
"devDependencies": {
3232
"@eslint/js": "^9.8.0",
@@ -43,7 +43,7 @@
4343
"vitest": "^4.0.5"
4444
},
4545
"dependencies": {
46-
"@modelcontextprotocol/sdk": "^1.20.1",
46+
"@modelcontextprotocol/sdk": "^1.22.0",
4747
"commander": "^14.0.2",
4848
"express": "^5.1.0",
4949
"lefthook": "^2.0.2",

src/scenarios/client/auth/basic-dcr.test.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/scenarios/client/auth/basic-dcr.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@ import { createAuthServer } from './helpers/createAuthServer.js';
44
import { createServer } from './helpers/createServer.js';
55
import { ServerLifecycle } from './helpers/serverLifecycle.js';
66
import { Request, Response } from 'express';
7+
import { SpecReferences } from './spec-references.js';
78

89
export class AuthBasicDCRScenario implements Scenario {
910
name = 'auth/basic-dcr';
1011
description =
1112
'Tests Basic OAuth flow with DCR, PRM at path-based location, OAuth metadata at root location, and no scopes required';
12-
private authServer = new ServerLifecycle(() => this.authBaseUrl);
13-
private server = new ServerLifecycle(() => this.baseUrl);
13+
private authServer = new ServerLifecycle();
14+
private server = new ServerLifecycle();
1415
private checks: ConformanceCheck[] = [];
15-
private baseUrl: string = '';
16-
private authBaseUrl: string = '';
1716

1817
async start(): Promise<ScenarioUrls> {
1918
this.checks = [];
2019

21-
const authApp = createAuthServer(this.checks, () => this.authBaseUrl);
22-
this.authBaseUrl = await this.authServer.start(authApp);
20+
const authApp = createAuthServer(this.checks, this.authServer.getUrl);
21+
await this.authServer.start(authApp);
2322

2423
const app = createServer(
2524
this.checks,
26-
() => this.baseUrl,
27-
() => this.authBaseUrl
25+
this.server.getUrl,
26+
this.authServer.getUrl
2827
);
2928

3029
// For this scenario, reject PRM requests at root location since we have the path-based PRM.
@@ -39,10 +38,8 @@ export class AuthBasicDCRScenario implements Scenario {
3938
status: 'FAILURE',
4039
timestamp: new Date().toISOString(),
4140
specReferences: [
42-
{
43-
id: 'mcp-authorization-prm',
44-
url: 'https://modelcontextprotocol.io/specification/draft/basic/authorization#protected-resource-metadata-discovery-requirements'
45-
}
41+
SpecReferences.RFC_PRM_DISCOVERY,
42+
SpecReferences.MCP_PRM_DISCOVERY
4643
],
4744
details: {
4845
url: req.url,
@@ -58,9 +55,9 @@ export class AuthBasicDCRScenario implements Scenario {
5855
}
5956
);
6057

61-
this.baseUrl = await this.server.start(app);
58+
await this.server.start(app);
6259

63-
return { serverUrl: `${this.baseUrl}/mcp` };
60+
return { serverUrl: `${this.server.getUrl()}/mcp` };
6461
}
6562

6663
async stop() {

src/scenarios/client/auth/basic-metadata-var1.test.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)