@@ -149,36 +149,34 @@ var ToolCountDown = TestTool[ToolCountDownArgs, any]{
149149 if err != nil {
150150 return nil , nil , err
151151 }
152- // change to use goroutine to not block the handler.
153- go func () {
154- for i := args .From ; i >= 0 ; i -- {
155- // Send a progress notification with the current count.
156- err := request .Session .NotifyProgress (ctx , & mcp.ProgressNotificationParams {
157- Message : fmt .Sprintf ("count down: %d" , i ),
158- ProgressToken : args .From - i ,
159- })
160- if err != nil {
161- return
162- }
163- // Send a log message with the debug and error levels so that
164- // we can test that setting log level works.
165- err = request .Session .Log (ctx , & mcp.LoggingMessageParams {
166- Level : "debug" ,
167- Data : `debug count down: ` + fmt .Sprint (i ),
168- })
169- if err != nil {
170- return
171- }
172- err = request .Session .Log (ctx , & mcp.LoggingMessageParams {
173- Level : "error" ,
174- Data : `count down: ` + fmt .Sprint (i ),
175- })
176- if err != nil {
177- return
178- }
179- time .Sleep (interval )
152+ for i := args .From ; i >= 0 ; i -- {
153+ // Send a progress notification with the current count.
154+ request .GetSession ()
155+ err := request .Session .NotifyProgress (ctx , & mcp.ProgressNotificationParams {
156+ Message : fmt .Sprintf ("count down: %d" , i ),
157+ ProgressToken : args .From - i ,
158+ })
159+ if err != nil {
160+ return nil , nil , err
161+ }
162+ // Send a log message with the debug and error levels so that
163+ // we can test that setting log level works.
164+ err = request .Session .Log (ctx , & mcp.LoggingMessageParams {
165+ Level : "debug" ,
166+ Data : `debug count down: ` + fmt .Sprint (i ),
167+ })
168+ if err != nil {
169+ return nil , nil , err
180170 }
181- }()
171+ err = request .Session .Log (ctx , & mcp.LoggingMessageParams {
172+ Level : "error" ,
173+ Data : `count down: ` + fmt .Sprint (i ),
174+ })
175+ if err != nil {
176+ return nil , nil , err
177+ }
178+ time .Sleep (interval )
179+ }
182180
183181 return & mcp.CallToolResult {
184182 Content : []mcp.Content {
0 commit comments