@@ -10,7 +10,7 @@ import (
1010 "k8s.io/utils/ptr"
1111
1212 "github.com/manusa/kubernetes-mcp-server/pkg/config"
13- "github.com/manusa/kubernetes-mcp-server/pkg/kubernetes"
13+ internalk8s "github.com/manusa/kubernetes-mcp-server/pkg/kubernetes"
1414 "github.com/manusa/kubernetes-mcp-server/pkg/output"
1515 "github.com/manusa/kubernetes-mcp-server/pkg/version"
1616)
@@ -41,7 +41,7 @@ func (c *Configuration) isToolApplicable(tool server.ServerTool) bool {
4141type Server struct {
4242 configuration * Configuration
4343 server * server.MCPServer
44- k * kubernetes .Manager
44+ k * internalk8s .Manager
4545}
4646
4747func NewServer (configuration Configuration ) (* Server , error ) {
@@ -65,7 +65,7 @@ func NewServer(configuration Configuration) (*Server, error) {
6565}
6666
6767func (s * Server ) reloadKubernetesClient () error {
68- k , err := kubernetes .NewManager (s .configuration .StaticConfig .KubeConfig , s .configuration .StaticConfig )
68+ k , err := internalk8s .NewManager (s .configuration .StaticConfig .KubeConfig , s .configuration .StaticConfig )
6969 if err != nil {
7070 return err
7171 }
@@ -132,5 +132,17 @@ func NewTextResult(content string, err error) *mcp.CallToolResult {
132132}
133133
134134func contextFunc (ctx context.Context , r * http.Request ) context.Context {
135- return context .WithValue (ctx , kubernetes .AuthorizationHeader , r .Header .Get (kubernetes .AuthorizationHeader ))
135+ // Get the standard Authorization header (OAuth compliant)
136+ authHeader := r .Header .Get (internalk8s .OAuthAuthorizationHeader )
137+ if authHeader != "" {
138+ return context .WithValue (ctx , internalk8s .OAuthAuthorizationHeader , authHeader )
139+ }
140+
141+ // Fallback to custom header for backward compatibility
142+ customAuthHeader := r .Header .Get (internalk8s .CustomAuthorizationHeader )
143+ if customAuthHeader != "" {
144+ return context .WithValue (ctx , internalk8s .OAuthAuthorizationHeader , customAuthHeader )
145+ }
146+
147+ return ctx
136148}
0 commit comments