@@ -622,6 +622,53 @@ describe("tool()", () => {
622
622
} ) ;
623
623
} ) ;
624
624
625
+ test ( "should register tool with description, empty params, and annotations" , async ( ) => {
626
+ const mcpServer = new McpServer ( {
627
+ name : "test server" ,
628
+ version : "1.0" ,
629
+ } ) ;
630
+ const client = new Client ( {
631
+ name : "test client" ,
632
+ version : "1.0" ,
633
+ } ) ;
634
+
635
+ mcpServer . tool (
636
+ "test" ,
637
+ "A tool with everything but empty params" ,
638
+ { } ,
639
+ { title : "Complete Test Tool with empty params" , readOnlyHint : true , openWorldHint : false } ,
640
+ async ( ) => ( {
641
+ content : [ { type : "text" , text : "Test response" } ]
642
+ } )
643
+ ) ;
644
+
645
+ const [ clientTransport , serverTransport ] =
646
+ InMemoryTransport . createLinkedPair ( ) ;
647
+
648
+ await Promise . all ( [
649
+ client . connect ( clientTransport ) ,
650
+ mcpServer . server . connect ( serverTransport ) ,
651
+ ] ) ;
652
+
653
+ const result = await client . request (
654
+ { method : "tools/list" } ,
655
+ ListToolsResultSchema ,
656
+ ) ;
657
+
658
+ expect ( result . tools ) . toHaveLength ( 1 ) ;
659
+ expect ( result . tools [ 0 ] . name ) . toBe ( "test" ) ;
660
+ expect ( result . tools [ 0 ] . description ) . toBe ( "A tool with everything but empty params" ) ;
661
+ expect ( result . tools [ 0 ] . inputSchema ) . toMatchObject ( {
662
+ type : "object" ,
663
+ properties : { }
664
+ } ) ;
665
+ expect ( result . tools [ 0 ] . annotations ) . toEqual ( {
666
+ title : "Complete Test Tool with empty params" ,
667
+ readOnlyHint : true ,
668
+ openWorldHint : false
669
+ } ) ;
670
+ } ) ;
671
+
625
672
test ( "should validate tool args" , async ( ) => {
626
673
const mcpServer = new McpServer ( {
627
674
name : "test server" ,
0 commit comments