@@ -13,83 +13,17 @@ const getServer = () => {
1313 version : '1.0.0' ,
1414 } , { capabilities : { logging : { } } } ) ;
1515
16- // Register a simple tool that returns a greeting
17- server . tool (
18- 'greet' ,
19- 'A simple greeting tool' ,
20- {
21- name : z . string ( ) . describe ( 'Name to greet' ) ,
22- } ,
23- async ( { name } ) : Promise < CallToolResult > => {
24- return {
25- content : [
26- {
27- type : 'text' ,
28- text : `Hello, ${ name } !` ,
29- } ,
30- ] ,
31- } ;
32- }
33- ) ;
34-
35- // Register a tool that sends multiple greetings with notifications (with annotations)
36- server . tool (
37- 'multi-greet' ,
38- 'A tool that sends different greetings with delays between them' ,
39- {
40- name : z . string ( ) . describe ( 'Name to greet' ) ,
41- } ,
42- {
43- title : 'Multiple Greeting Tool' ,
44- readOnlyHint : true ,
45- openWorldHint : false
46- } ,
47- async ( { name } , { sendNotification } ) : Promise < CallToolResult > => {
48- const sleep = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
49-
50- await sendNotification ( {
51- method : "notifications/message" ,
52- params : { level : "debug" , data : `Starting multi-greet for ${ name } ` }
53- } ) ;
54-
55- await sleep ( 1000 ) ; // Wait 1 second before first greeting
56-
57- await sendNotification ( {
58- method : "notifications/message" ,
59- params : { level : "info" , data : `Sending first greeting to ${ name } ` }
60- } ) ;
61-
62- await sleep ( 1000 ) ; // Wait another second before second greeting
63-
64- await sendNotification ( {
65- method : "notifications/message" ,
66- params : { level : "info" , data : `Sending second greeting to ${ name } ` }
67- } ) ;
68-
69- return {
70- content : [
71- {
72- type : 'text' ,
73- text : `Good morning, ${ name } !` ,
74- }
75- ] ,
76- } ;
77- }
78- ) ;
79-
80- // Register a simple prompt
81- server . prompt (
82- 'greeting-template' ,
83- 'A simple greeting prompt template' ,
84- {
85- name : z . string ( ) . describe ( 'Name to include in greeting' ) ,
86- } ,
87- async ( { name } ) : Promise < GetPromptResult > => {
88- return {
89- messages : [
90- {
91- role : 'user' ,
92- content : {
16+ // Register a simple tool that returns a greeting
17+ server . tool (
18+ 'greet' ,
19+ 'A simple greeting tool' ,
20+ {
21+ name : z . string ( ) . describe ( 'Name to greet' ) ,
22+ } ,
23+ async ( { name } ) : Promise < CallToolResult > => {
24+ return {
25+ content : [
26+ {
9327 type : 'text' ,
9428 text : `Hello, ${ name } !` ,
9529 } ,
@@ -98,13 +32,18 @@ server.prompt(
9832 }
9933 ) ;
10034
101- // Register a tool that sends multiple greetings with notifications
35+ // Register a tool that sends multiple greetings with notifications (with annotations)
10236 server . tool (
10337 'multi-greet' ,
10438 'A tool that sends different greetings with delays between them' ,
10539 {
10640 name : z . string ( ) . describe ( 'Name to greet' ) ,
10741 } ,
42+ {
43+ title : 'Multiple Greeting Tool' ,
44+ readOnlyHint : true ,
45+ openWorldHint : false
46+ } ,
10847 async ( { name } , { sendNotification } ) : Promise < CallToolResult > => {
10948 const sleep = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
11049
0 commit comments