Skip to content

Commit 29b65fd

Browse files
authored
fix: linting issues (#240)
Signed-off-by: Marc Nuri <[email protected]>
1 parent 73af678 commit 29b65fd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/mcp/mcp.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"k8s.io/klog/v2"
87
"net/http"
98
"slices"
109

1110
"github.com/mark3labs/mcp-go/mcp"
1211
"github.com/mark3labs/mcp-go/server"
1312
authenticationapiv1 "k8s.io/api/authentication/v1"
13+
"k8s.io/klog/v2"
1414
"k8s.io/utils/ptr"
1515

1616
"github.com/containers/kubernetes-mcp-server/pkg/config"
@@ -19,7 +19,9 @@ import (
1919
"github.com/containers/kubernetes-mcp-server/pkg/version"
2020
)
2121

22-
const TokenScopesContextKey = "TokenScopesContextKey"
22+
type ContextKey string
23+
24+
const TokenScopesContextKey = ContextKey("TokenScopesContextKey")
2325

2426
type Configuration struct {
2527
Profile Profile
@@ -202,10 +204,10 @@ func toolScopedAuthorizationMiddleware(next server.ToolHandlerFunc) server.ToolH
202204
return func(ctx context.Context, ctr mcp.CallToolRequest) (*mcp.CallToolResult, error) {
203205
scopes, ok := ctx.Value(TokenScopesContextKey).([]string)
204206
if !ok {
205-
return NewTextResult("", fmt.Errorf("Authorization failed: Access denied: Tool '%s' requires scope 'mcp:%s' but no scope is available", ctr.Params.Name, ctr.Params.Name)), nil
207+
return NewTextResult("", fmt.Errorf("authorization failed: Access denied: Tool '%s' requires scope 'mcp:%s' but no scope is available", ctr.Params.Name, ctr.Params.Name)), nil
206208
}
207209
if !slices.Contains(scopes, "mcp:"+ctr.Params.Name) && !slices.Contains(scopes, ctr.Params.Name) {
208-
return NewTextResult("", fmt.Errorf("Authorization failed: Access denied: Tool '%s' requires scope 'mcp:%s' but only scopes %s are available", ctr.Params.Name, ctr.Params.Name, scopes)), nil
210+
return NewTextResult("", fmt.Errorf("authorization failed: Access denied: Tool '%s' requires scope 'mcp:%s' but only scopes %s are available", ctr.Params.Name, ctr.Params.Name, scopes)), nil
209211
}
210212
return next(ctx, ctr)
211213
}

0 commit comments

Comments
 (0)