Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/http/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
func AuthorizationMiddleware(requireOAuth bool, serverURL string, mcpServer *mcp.Server) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/healthz" || r.URL.Path == "/.well-known/oauth-protected-resource" {
if r.URL.Path == healthEndpoint || r.URL.Path == oauthProtectedResourceEndpoint {
next.ServeHTTP(w, r)
return
}
Expand Down
16 changes: 11 additions & 5 deletions pkg/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ import (
"github.com/manusa/kubernetes-mcp-server/pkg/mcp"
)

const oauthProtectedResourceEndpoint = "/.well-known/oauth-protected-resource"
const (
oauthProtectedResourceEndpoint = "/.well-known/oauth-protected-resource"
healthEndpoint = "/healthz"
mcpEndpoint = "/mcp"
sseEndpoint = "/sse"
sseMessageEndpoint = "/message"
)

func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.StaticConfig) error {
mux := http.NewServeMux()
Expand All @@ -32,10 +38,10 @@ func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.Stat

sseServer := mcpServer.ServeSse(staticConfig.SSEBaseURL, httpServer)
streamableHttpServer := mcpServer.ServeHTTP(httpServer)
mux.Handle("/sse", sseServer)
mux.Handle("/message", sseServer)
mux.Handle("/mcp", streamableHttpServer)
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
mux.Handle(sseEndpoint, sseServer)
mux.Handle(sseMessageEndpoint, sseServer)
mux.Handle(mcpEndpoint, streamableHttpServer)
mux.HandleFunc(healthEndpoint, func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
mux.HandleFunc(oauthProtectedResourceEndpoint, func(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading