@@ -16,6 +16,7 @@ import { ElicitRequestSchema } from '../../../src/types.js';
1616import { z } from 'zod' ;
1717
1818import { logger } from './helpers/logger.js' ;
19+ import { ConformanceOAuthProvider } from './helpers/conformanceOAuthProvider.js' ;
1920import { handle401 , withOAuthRetry } from './helpers/withOAuthRetry.js' ;
2021
2122/**
@@ -37,6 +38,11 @@ const ClientConformanceContextSchema = z.discriminatedUnion('name', [
3738 name : z . literal ( 'auth/client-credentials-basic' ) ,
3839 client_id : z . string ( ) ,
3940 client_secret : z . string ( )
41+ } ) ,
42+ z . object ( {
43+ name : z . literal ( 'auth/pre-registration' ) ,
44+ client_id : z . string ( ) ,
45+ client_secret : z . string ( )
4046 } )
4147] ) ;
4248
@@ -228,6 +234,43 @@ async function runClientCredentialsBasic(serverUrl: string): Promise<void> {
228234
229235registerScenario ( 'auth/client-credentials-basic' , runClientCredentialsBasic ) ;
230236
237+ // ============================================================================
238+ // Pre-registration scenario (no dynamic client registration)
239+ // ============================================================================
240+
241+ async function runPreRegistrationClient ( serverUrl : string ) : Promise < void > {
242+ const ctx = parseContext ( ) ;
243+ if ( ctx . name !== 'auth/pre-registration' ) {
244+ throw new Error ( `Expected pre-registration context, got ${ ctx . name } ` ) ;
245+ }
246+
247+ // Create a provider pre-populated with registered credentials,
248+ // so the SDK skips dynamic client registration.
249+ const provider = new ConformanceOAuthProvider ( 'http://localhost:3000/callback' , {
250+ client_name : 'conformance-pre-registration' ,
251+ redirect_uris : [ 'http://localhost:3000/callback' ]
252+ } ) ;
253+ provider . saveClientInformation ( {
254+ client_id : ctx . client_id ,
255+ client_secret : ctx . client_secret ,
256+ redirect_uris : [ 'http://localhost:3000/callback' ]
257+ } ) ;
258+
259+ const oauthFetch = withOAuthRetry ( 'conformance-pre-registration' , new URL ( serverUrl ) , handle401 , undefined , provider ) ( fetch ) ;
260+
261+ const client = new Client ( { name : 'conformance-pre-registration' , version : '1.0.0' } , { capabilities : { } } ) ;
262+ const transport = new StreamableHTTPClientTransport ( new URL ( serverUrl ) , {
263+ fetch : oauthFetch
264+ } ) ;
265+
266+ await client . connect ( transport ) ;
267+ await client . listTools ( ) ;
268+ await client . callTool ( { name : 'test-tool' , arguments : { } } ) ;
269+ await transport . close ( ) ;
270+ }
271+
272+ registerScenario ( 'auth/pre-registration' , runPreRegistrationClient ) ;
273+
231274// ============================================================================
232275// Elicitation defaults scenario
233276// ============================================================================
0 commit comments