Skip to content

Commit eaa6f29

Browse files
authored
chore: remove unused variables and type arguments (#302)
1 parent 65010c4 commit eaa6f29

File tree

3 files changed

+202
-78
lines changed

3 files changed

+202
-78
lines changed

server/server.go

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ func WithRecovery() ServerOption {
220220
return func(ctx context.Context, request mcp.CallToolRequest) (result *mcp.CallToolResult, err error) {
221221
defer func() {
222222
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+
)
224228
}
225229
}()
226230
return next(ctx, request)
@@ -487,8 +491,8 @@ func (s *MCPServer) AddNotificationHandler(
487491

488492
func (s *MCPServer) handleInitialize(
489493
ctx context.Context,
490-
id any,
491-
request mcp.InitializeRequest,
494+
_ any,
495+
_ mcp.InitializeRequest,
492496
) (*mcp.InitializeResult, *requestError) {
493497
capabilities := mcp.ServerCapabilities{}
494498

@@ -542,9 +546,9 @@ func (s *MCPServer) handleInitialize(
542546
}
543547

544548
func (s *MCPServer) handlePing(
545-
ctx context.Context,
546-
id any,
547-
request mcp.PingRequest,
549+
_ context.Context,
550+
_ any,
551+
_ mcp.PingRequest,
548552
) (*mcp.EmptyResult, *requestError) {
549553
return &mcp.EmptyResult{}, nil
550554
}
@@ -586,14 +590,14 @@ func (s *MCPServer) handleSetLevel(
586590
err: fmt.Errorf("invalid logging level '%s'", level),
587591
}
588592
}
589-
593+
590594
sessionLogging.SetLogLevel(level)
591595

592596
return &mcp.EmptyResult{}, nil
593597
}
594598

595599
func listByPagination[T mcp.Named](
596-
ctx context.Context,
600+
_ context.Context,
597601
s *MCPServer,
598602
cursor mcp.Cursor,
599603
allElements []T,
@@ -644,7 +648,12 @@ func (s *MCPServer) handleListResources(
644648
sort.Slice(resources, func(i, j int) bool {
645649
return resources[i].Name < resources[j].Name
646650
})
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+
)
648657
if err != nil {
649658
return nil, &requestError{
650659
id: id,
@@ -675,7 +684,12 @@ func (s *MCPServer) handleListResourceTemplates(
675684
sort.Slice(templates, func(i, j int) bool {
676685
return templates[i].Name < templates[j].Name
677686
})
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+
)
679693
if err != nil {
680694
return nil, &requestError{
681695
id: id,
@@ -747,7 +761,11 @@ func (s *MCPServer) handleReadResource(
747761
return nil, &requestError{
748762
id: id,
749763
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+
),
751769
}
752770
}
753771

@@ -772,7 +790,12 @@ func (s *MCPServer) handleListPrompts(
772790
sort.Slice(prompts, func(i, j int) bool {
773791
return prompts[i].Name < prompts[j].Name
774792
})
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+
)
776799
if err != nil {
777800
return nil, &requestError{
778801
id: id,
@@ -885,7 +908,12 @@ func (s *MCPServer) handleListTools(
885908
s.toolFiltersMu.RUnlock()
886909

887910
// 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+
)
889917
if err != nil {
890918
return nil, &requestError{
891919
id: id,

server/server_race_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ func TestRaceConditions(t *testing.T) {
126126
}
127127

128128
// Helper function to run an operation concurrently for a specified duration
129-
func runConcurrentOperation(wg *sync.WaitGroup, duration time.Duration, name string, operation func()) {
129+
func runConcurrentOperation(
130+
wg *sync.WaitGroup,
131+
duration time.Duration,
132+
_ string,
133+
operation func(),
134+
) {
130135
wg.Add(1)
131136
go func() {
132137
defer wg.Done()

0 commit comments

Comments
 (0)