@@ -310,6 +310,19 @@ describe("tool()", () => {
310
310
} ) . toThrow ( / a l r e a d y r e g i s t e r e d / ) ;
311
311
} ) ;
312
312
313
+ test ( "should allow registering multiple tools" , ( ) => {
314
+ const mcpServer = new McpServer ( {
315
+ name : "test server" ,
316
+ version : "1.0" ,
317
+ } ) ;
318
+
319
+ // This should succeed
320
+ mcpServer . tool ( "tool1" , ( ) => ( { content : [ ] } ) ) ;
321
+
322
+ // This should also succeed and not throw about request handlers
323
+ mcpServer . tool ( "tool2" , ( ) => ( { content : [ ] } ) ) ;
324
+ } ) ;
325
+
313
326
test ( "should allow client to call server tools" , async ( ) => {
314
327
const mcpServer = new McpServer ( {
315
328
name : "test server" ,
@@ -734,6 +747,33 @@ describe("resource()", () => {
734
747
} ) . toThrow ( / a l r e a d y r e g i s t e r e d / ) ;
735
748
} ) ;
736
749
750
+ test ( "should allow registering multiple resources" , ( ) => {
751
+ const mcpServer = new McpServer ( {
752
+ name : "test server" ,
753
+ version : "1.0" ,
754
+ } ) ;
755
+
756
+ // This should succeed
757
+ mcpServer . resource ( "resource1" , "test://resource1" , async ( ) => ( {
758
+ contents : [
759
+ {
760
+ uri : "test://resource1" ,
761
+ text : "Test content 1" ,
762
+ } ,
763
+ ] ,
764
+ } ) ) ;
765
+
766
+ // This should also succeed and not throw about request handlers
767
+ mcpServer . resource ( "resource2" , "test://resource2" , async ( ) => ( {
768
+ contents : [
769
+ {
770
+ uri : "test://resource2" ,
771
+ text : "Test content 2" ,
772
+ } ,
773
+ ] ,
774
+ } ) ) ;
775
+ } ) ;
776
+
737
777
test ( "should prevent duplicate resource template registration" , ( ) => {
738
778
const mcpServer = new McpServer ( {
739
779
name : "test server" ,
@@ -1210,6 +1250,39 @@ describe("prompt()", () => {
1210
1250
} ) . toThrow ( / a l r e a d y r e g i s t e r e d / ) ;
1211
1251
} ) ;
1212
1252
1253
+ test ( "should allow registering multiple prompts" , ( ) => {
1254
+ const mcpServer = new McpServer ( {
1255
+ name : "test server" ,
1256
+ version : "1.0" ,
1257
+ } ) ;
1258
+
1259
+ // This should succeed
1260
+ mcpServer . prompt ( "prompt1" , async ( ) => ( {
1261
+ messages : [
1262
+ {
1263
+ role : "assistant" ,
1264
+ content : {
1265
+ type : "text" ,
1266
+ text : "Test response 1" ,
1267
+ } ,
1268
+ } ,
1269
+ ] ,
1270
+ } ) ) ;
1271
+
1272
+ // This should also succeed and not throw about request handlers
1273
+ mcpServer . prompt ( "prompt2" , async ( ) => ( {
1274
+ messages : [
1275
+ {
1276
+ role : "assistant" ,
1277
+ content : {
1278
+ type : "text" ,
1279
+ text : "Test response 2" ,
1280
+ } ,
1281
+ } ,
1282
+ ] ,
1283
+ } ) ) ;
1284
+ } ) ;
1285
+
1213
1286
test ( "should throw McpError for invalid prompt name" , async ( ) => {
1214
1287
const mcpServer = new McpServer ( {
1215
1288
name : "test server" ,
0 commit comments