@@ -220,7 +220,11 @@ func WithRecovery() ServerOption {
220
220
return func (ctx context.Context , request mcp.CallToolRequest ) (result * mcp.CallToolResult , err error ) {
221
221
defer func () {
222
222
if r := recover (); r != nil {
223
- err = fmt .Errorf ("panic recovered in %s tool handler: %v" , request .Params .Name , r )
223
+ err = fmt .Errorf (
224
+ "panic recovered in %s tool handler: %v" ,
225
+ request .Params .Name ,
226
+ r ,
227
+ )
224
228
}
225
229
}()
226
230
return next (ctx , request )
@@ -487,8 +491,8 @@ func (s *MCPServer) AddNotificationHandler(
487
491
488
492
func (s * MCPServer ) handleInitialize (
489
493
ctx context.Context ,
490
- id any ,
491
- request mcp.InitializeRequest ,
494
+ _ any ,
495
+ _ mcp.InitializeRequest ,
492
496
) (* mcp.InitializeResult , * requestError ) {
493
497
capabilities := mcp.ServerCapabilities {}
494
498
@@ -542,9 +546,9 @@ func (s *MCPServer) handleInitialize(
542
546
}
543
547
544
548
func (s * MCPServer ) handlePing (
545
- ctx context.Context ,
546
- id any ,
547
- request mcp.PingRequest ,
549
+ _ context.Context ,
550
+ _ any ,
551
+ _ mcp.PingRequest ,
548
552
) (* mcp.EmptyResult , * requestError ) {
549
553
return & mcp.EmptyResult {}, nil
550
554
}
@@ -586,14 +590,14 @@ func (s *MCPServer) handleSetLevel(
586
590
err : fmt .Errorf ("invalid logging level '%s'" , level ),
587
591
}
588
592
}
589
-
593
+
590
594
sessionLogging .SetLogLevel (level )
591
595
592
596
return & mcp.EmptyResult {}, nil
593
597
}
594
598
595
599
func listByPagination [T mcp.Named ](
596
- ctx context.Context ,
600
+ _ context.Context ,
597
601
s * MCPServer ,
598
602
cursor mcp.Cursor ,
599
603
allElements []T ,
@@ -644,7 +648,12 @@ func (s *MCPServer) handleListResources(
644
648
sort .Slice (resources , func (i , j int ) bool {
645
649
return resources [i ].Name < resources [j ].Name
646
650
})
647
- resourcesToReturn , nextCursor , err := listByPagination [mcp.Resource ](ctx , s , request .Params .Cursor , resources )
651
+ resourcesToReturn , nextCursor , err := listByPagination (
652
+ ctx ,
653
+ s ,
654
+ request .Params .Cursor ,
655
+ resources ,
656
+ )
648
657
if err != nil {
649
658
return nil , & requestError {
650
659
id : id ,
@@ -675,7 +684,12 @@ func (s *MCPServer) handleListResourceTemplates(
675
684
sort .Slice (templates , func (i , j int ) bool {
676
685
return templates [i ].Name < templates [j ].Name
677
686
})
678
- templatesToReturn , nextCursor , err := listByPagination [mcp.ResourceTemplate ](ctx , s , request .Params .Cursor , templates )
687
+ templatesToReturn , nextCursor , err := listByPagination (
688
+ ctx ,
689
+ s ,
690
+ request .Params .Cursor ,
691
+ templates ,
692
+ )
679
693
if err != nil {
680
694
return nil , & requestError {
681
695
id : id ,
@@ -747,7 +761,11 @@ func (s *MCPServer) handleReadResource(
747
761
return nil , & requestError {
748
762
id : id ,
749
763
code : mcp .RESOURCE_NOT_FOUND ,
750
- err : fmt .Errorf ("handler not found for resource URI '%s': %w" , request .Params .URI , ErrResourceNotFound ),
764
+ err : fmt .Errorf (
765
+ "handler not found for resource URI '%s': %w" ,
766
+ request .Params .URI ,
767
+ ErrResourceNotFound ,
768
+ ),
751
769
}
752
770
}
753
771
@@ -772,7 +790,12 @@ func (s *MCPServer) handleListPrompts(
772
790
sort .Slice (prompts , func (i , j int ) bool {
773
791
return prompts [i ].Name < prompts [j ].Name
774
792
})
775
- promptsToReturn , nextCursor , err := listByPagination [mcp.Prompt ](ctx , s , request .Params .Cursor , prompts )
793
+ promptsToReturn , nextCursor , err := listByPagination (
794
+ ctx ,
795
+ s ,
796
+ request .Params .Cursor ,
797
+ prompts ,
798
+ )
776
799
if err != nil {
777
800
return nil , & requestError {
778
801
id : id ,
@@ -885,7 +908,12 @@ func (s *MCPServer) handleListTools(
885
908
s .toolFiltersMu .RUnlock ()
886
909
887
910
// Apply pagination
888
- toolsToReturn , nextCursor , err := listByPagination [mcp.Tool ](ctx , s , request .Params .Cursor , tools )
911
+ toolsToReturn , nextCursor , err := listByPagination (
912
+ ctx ,
913
+ s ,
914
+ request .Params .Cursor ,
915
+ tools ,
916
+ )
889
917
if err != nil {
890
918
return nil , & requestError {
891
919
id : id ,
0 commit comments