@@ -2,7 +2,6 @@ package http
2
2
3
3
import (
4
4
"context"
5
- "encoding/json"
6
5
"errors"
7
6
"net/http"
8
7
"os"
@@ -19,11 +18,10 @@ import (
19
18
)
20
19
21
20
const (
22
- oauthProtectedResourceEndpoint = "/.well-known/oauth-protected-resource"
23
- healthEndpoint = "/healthz"
24
- mcpEndpoint = "/mcp"
25
- sseEndpoint = "/sse"
26
- sseMessageEndpoint = "/message"
21
+ healthEndpoint = "/healthz"
22
+ mcpEndpoint = "/mcp"
23
+ sseEndpoint = "/sse"
24
+ sseMessageEndpoint = "/message"
27
25
)
28
26
29
27
func Serve (ctx context.Context , mcpServer * mcp.Server , staticConfig * config.StaticConfig , oidcProvider * oidc.Provider ) error {
@@ -46,39 +44,7 @@ func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.Stat
46
44
mux .HandleFunc (healthEndpoint , func (w http.ResponseWriter , r * http.Request ) {
47
45
w .WriteHeader (http .StatusOK )
48
46
})
49
- mux .HandleFunc (oauthProtectedResourceEndpoint , func (w http.ResponseWriter , r * http.Request ) {
50
- w .Header ().Set ("Content-Type" , "application/json" )
51
-
52
- var authServers []string
53
- if staticConfig .AuthorizationURL != "" {
54
- authServers = []string {staticConfig .AuthorizationURL }
55
- } else {
56
- // Fallback to Kubernetes API server host if authorization_server is not configured
57
- if apiServerHost := mcpServer .GetKubernetesAPIServerHost (); apiServerHost != "" {
58
- authServers = []string {apiServerHost }
59
- }
60
- }
61
-
62
- response := map [string ]interface {}{
63
- "authorization_servers" : authServers ,
64
- "authorization_server" : authServers [0 ],
65
- "scopes_supported" : mcpServer .GetEnabledTools (),
66
- "bearer_methods_supported" : []string {"header" },
67
- }
68
-
69
- if staticConfig .ServerURL != "" {
70
- response ["resource" ] = staticConfig .ServerURL
71
- }
72
-
73
- if staticConfig .JwksURL != "" {
74
- response ["jwks_uri" ] = staticConfig .JwksURL
75
- }
76
-
77
- w .WriteHeader (http .StatusOK )
78
- if err := json .NewEncoder (w ).Encode (response ); err != nil {
79
- http .Error (w , err .Error (), http .StatusInternalServerError )
80
- }
81
- })
47
+ mux .HandleFunc (oauthProtectedResourceEndpoint , OAuthProtectedResourceHandler (mcpServer , staticConfig ))
82
48
83
49
ctx , cancel := context .WithCancel (ctx )
84
50
defer cancel ()
0 commit comments