@@ -2321,6 +2321,48 @@ describe("resource()", () => {
23212321 ) . rejects . toThrow ( / R e s o u r c e t e s t : \/ \/ n o n e x i s t e n t n o t f o u n d / ) ;
23222322 } ) ;
23232323
2324+ /***
2325+ * Test: Registering a resource template with a complete callback should update server capabilities to advertise support for completion
2326+ */
2327+ test ( "should advertise support for completion when a resource template with a complete callback is defined" , async ( ) => {
2328+ const mcpServer = new McpServer ( {
2329+ name : "test server" ,
2330+ version : "1.0" ,
2331+ } ) ;
2332+ const client = new Client ( {
2333+ name : "test client" ,
2334+ version : "1.0" ,
2335+ } ) ;
2336+
2337+ mcpServer . resource (
2338+ "test" ,
2339+ new ResourceTemplate ( "test://resource/{category}" , {
2340+ list : undefined ,
2341+ complete : {
2342+ category : ( ) => [ "books" , "movies" , "music" ] ,
2343+ } ,
2344+ } ) ,
2345+ async ( ) => ( {
2346+ contents : [
2347+ {
2348+ uri : "test://resource/test" ,
2349+ text : "Test content" ,
2350+ } ,
2351+ ] ,
2352+ } ) ,
2353+ ) ;
2354+
2355+ const [ clientTransport , serverTransport ] =
2356+ InMemoryTransport . createLinkedPair ( ) ;
2357+
2358+ await Promise . all ( [
2359+ client . connect ( clientTransport ) ,
2360+ mcpServer . server . connect ( serverTransport ) ,
2361+ ] ) ;
2362+
2363+ expect ( client . getServerCapabilities ( ) ) . toMatchObject ( { completions : { } } )
2364+ } )
2365+
23242366 /***
23252367 * Test: Resource Template Parameter Completion
23262368 */
@@ -3197,6 +3239,49 @@ describe("prompt()", () => {
31973239 ) . rejects . toThrow ( / P r o m p t n o n e x i s t e n t - p r o m p t n o t f o u n d / ) ;
31983240 } ) ;
31993241
3242+
3243+ /***
3244+ * Test: Registering a prompt with a completable argument should update server capabilities to advertise support for completion
3245+ */
3246+ test ( "should advertise support for completion when a prompt with a completable argument is defined" , async ( ) => {
3247+ const mcpServer = new McpServer ( {
3248+ name : "test server" ,
3249+ version : "1.0" ,
3250+ } ) ;
3251+ const client = new Client ( {
3252+ name : "test client" ,
3253+ version : "1.0" ,
3254+ } ) ;
3255+
3256+ mcpServer . prompt (
3257+ "test-prompt" ,
3258+ {
3259+ name : completable ( z . string ( ) , ( ) => [ "Alice" , "Bob" , "Charlie" ] ) ,
3260+ } ,
3261+ async ( { name } ) => ( {
3262+ messages : [
3263+ {
3264+ role : "assistant" ,
3265+ content : {
3266+ type : "text" ,
3267+ text : `Hello ${ name } ` ,
3268+ } ,
3269+ } ,
3270+ ] ,
3271+ } ) ,
3272+ ) ;
3273+
3274+ const [ clientTransport , serverTransport ] =
3275+ InMemoryTransport . createLinkedPair ( ) ;
3276+
3277+ await Promise . all ( [
3278+ client . connect ( clientTransport ) ,
3279+ mcpServer . server . connect ( serverTransport ) ,
3280+ ] ) ;
3281+
3282+ expect ( client . getServerCapabilities ( ) ) . toMatchObject ( { completions : { } } )
3283+ } )
3284+
32003285 /***
32013286 * Test: Prompt Argument Completion
32023287 */
0 commit comments