@@ -463,14 +463,14 @@ describe("tool()", () => {
463463 ) ;
464464
465465 // new api
466- mcpServer . tool (
466+ mcpServer . registerTool (
467467 "test (new api)" ,
468- {
469- inputSchema : { name : z . string ( ) , value : z . number ( ) } ,
470- callback : async ( { name , value } ) => ( {
471- content : [ { type : "text" , text : ` ${ name } : ${ value } ` } ] ,
472- } ) ,
473- }
468+ {
469+ inputSchema : { name : z . string ( ) , value : z . number ( ) } ,
470+ } ,
471+ async ( { name , value } ) => ( {
472+ content : [ { type : "text" , text : ` ${ name } : ${ value } ` } ] ,
473+ } )
474474 ) ;
475475
476476 const [ clientTransport , serverTransport ] =
@@ -525,17 +525,20 @@ describe("tool()", () => {
525525 } ) ) ;
526526
527527 // new api
528- mcpServer . tool ( "test (new api)" , {
529- description : "Test description" ,
530- callback : async ( ) => ( {
528+ mcpServer . registerTool (
529+ "test (new api)" ,
530+ {
531+ description : "Test description" ,
532+ } ,
533+ async ( ) => ( {
531534 content : [
532535 {
533536 type : "text" as const ,
534537 text : "Test response" ,
535538 } ,
536539 ] ,
537540 } )
538- } ) ;
541+ ) ;
539542
540543
541544 const [ clientTransport , serverTransport ] =
@@ -582,17 +585,20 @@ describe("tool()", () => {
582585 ] ,
583586 } ) ) ;
584587
585- mcpServer . tool ( "test (new api)" , {
586- annotations : { title : "Test Tool" , readOnlyHint : true } ,
587- callback : async ( ) => ( {
588+ mcpServer . registerTool (
589+ "test (new api)" ,
590+ {
591+ annotations : { title : "Test Tool" , readOnlyHint : true } ,
592+ } ,
593+ async ( ) => ( {
588594 content : [
589595 {
590596 type : "text" as const ,
591597 text : "Test response" ,
592598 } ,
593599 ] ,
594- } ) ,
595- } ) ;
600+ } )
601+ ) ;
596602
597603 const [ clientTransport , serverTransport ] =
598604 InMemoryTransport . createLinkedPair ( ) ;
@@ -638,13 +644,16 @@ describe("tool()", () => {
638644 } )
639645 ) ;
640646
641- mcpServer . tool ( "test (new api)" , {
642- inputSchema : { name : z . string ( ) } ,
643- annotations : { title : "Test Tool" , readOnlyHint : true } ,
644- callback : async ( { name } ) => ( {
647+ mcpServer . registerTool (
648+ "test (new api)" ,
649+ {
650+ inputSchema : { name : z . string ( ) } ,
651+ annotations : { title : "Test Tool" , readOnlyHint : true } ,
652+ } ,
653+ async ( { name } ) => ( {
645654 content : [ { type : "text" , text : `Hello, ${ name } !` } ]
646655 } )
647- } ) ;
656+ ) ;
648657
649658 const [ clientTransport , serverTransport ] =
650659 InMemoryTransport . createLinkedPair ( ) ;
@@ -694,14 +703,17 @@ describe("tool()", () => {
694703 } )
695704 ) ;
696705
697- mcpServer . tool ( "test (new api)" , {
698- description : "A tool with everything" ,
699- inputSchema : { name : z . string ( ) } ,
700- annotations : { title : "Complete Test Tool" , readOnlyHint : true , openWorldHint : false } ,
701- callback : async ( { name } ) => ( {
706+ mcpServer . registerTool (
707+ "test (new api)" ,
708+ {
709+ description : "A tool with everything" ,
710+ inputSchema : { name : z . string ( ) } ,
711+ annotations : { title : "Complete Test Tool" , readOnlyHint : true , openWorldHint : false } ,
712+ } ,
713+ async ( { name } ) => ( {
702714 content : [ { type : "text" , text : `Hello, ${ name } !` } ]
703715 } )
704- } ) ;
716+ ) ;
705717
706718 const [ clientTransport , serverTransport ] =
707719 InMemoryTransport . createLinkedPair ( ) ;
@@ -757,14 +769,17 @@ describe("tool()", () => {
757769 } )
758770 ) ;
759771
760- mcpServer . tool ( "test (new api)" , {
761- description : "A tool with everything but empty params" ,
762- inputSchema : { } ,
763- annotations : { title : "Complete Test Tool with empty params" , readOnlyHint : true , openWorldHint : false } ,
764- callback : async ( ) => ( {
772+ mcpServer . registerTool (
773+ "test (new api)" ,
774+ {
775+ description : "A tool with everything but empty params" ,
776+ inputSchema : { } ,
777+ annotations : { title : "Complete Test Tool with empty params" , readOnlyHint : true , openWorldHint : false } ,
778+ } ,
779+ async ( ) => ( {
765780 content : [ { type : "text" as const , text : "Test response" } ]
766781 } )
767- } ) ;
782+ ) ;
768783
769784 const [ clientTransport , serverTransport ] =
770785 InMemoryTransport . createLinkedPair ( ) ;
@@ -834,20 +849,23 @@ describe("tool()", () => {
834849 } ) ,
835850 ) ;
836851
837- mcpServer . tool ( "test (new api)" , {
838- inputSchema : {
839- name : z . string ( ) ,
840- value : z . number ( ) ,
852+ mcpServer . registerTool (
853+ "test (new api)" ,
854+ {
855+ inputSchema : {
856+ name : z . string ( ) ,
857+ value : z . number ( ) ,
858+ } ,
841859 } ,
842- callback : async ( { name, value } ) => ( {
860+ async ( { name, value } ) => ( {
843861 content : [
844862 {
845863 type : "text" ,
846864 text : `${ name } : ${ value } ` ,
847865 } ,
848866 ] ,
849- } ) ,
850- } ) ;
867+ } )
868+ ) ;
851869
852870 const [ clientTransport , serverTransport ] =
853871 InMemoryTransport . createLinkedPair ( ) ;
@@ -958,7 +976,7 @@ describe("tool()", () => {
958976 ) ;
959977
960978 // Register a tool with outputSchema
961- mcpServer . tool (
979+ mcpServer . registerTool (
962980 "test" ,
963981 {
964982 description : "Test tool with structured output" ,
@@ -970,14 +988,14 @@ describe("tool()", () => {
970988 resultType : z . string ( ) ,
971989 timestamp : z . string ( )
972990 } ,
973- callback : async ( { input } ) => ( {
974- structuredContent : {
975- processedInput : input ,
976- resultType : "structured" ,
977- timestamp : "2023-01-01T00:00:00Z"
978- } ,
979- } ) ,
980991 } ,
992+ async ( { input } ) => ( {
993+ structuredContent : {
994+ processedInput : input ,
995+ resultType : "structured" ,
996+ timestamp : "2023-01-01T00:00:00Z"
997+ } ,
998+ } )
981999 ) ;
9821000
9831001 const [ clientTransport , serverTransport ] =
@@ -1061,7 +1079,7 @@ describe("tool()", () => {
10611079 ) ;
10621080
10631081 // Register a tool with outputSchema that returns invalid data
1064- mcpServer . tool (
1082+ mcpServer . registerTool (
10651083 "test" ,
10661084 {
10671085 description : "Test tool with invalid structured output" ,
@@ -1073,15 +1091,15 @@ describe("tool()", () => {
10731091 resultType : z . string ( ) ,
10741092 timestamp : z . string ( )
10751093 } ,
1076- callback : async ( { input } ) => ( {
1077- structuredContent : {
1078- processedInput : input ,
1079- resultType : "structured" ,
1080- // Missing required 'timestamp' field
1081- someExtraField : "unexpected" // Extra field not in schema
1082- } ,
1083- } ) ,
10841094 } ,
1095+ async ( { input } ) => ( {
1096+ structuredContent : {
1097+ processedInput : input ,
1098+ resultType : "structured" ,
1099+ // Missing required 'timestamp' field
1100+ someExtraField : "unexpected" // Extra field not in schema
1101+ } ,
1102+ } )
10851103 ) ;
10861104
10871105 const [ clientTransport , serverTransport ] =
0 commit comments