|
7 | 7 | "github.com/manusa/kubernetes-mcp-server/pkg/mcp"
|
8 | 8 | "github.com/manusa/kubernetes-mcp-server/pkg/output"
|
9 | 9 | "github.com/manusa/kubernetes-mcp-server/pkg/version"
|
10 |
| - "github.com/mark3labs/mcp-go/server" |
11 | 10 | "github.com/spf13/cobra"
|
12 | 11 | "github.com/spf13/viper"
|
13 | 12 | "golang.org/x/net/context"
|
@@ -74,16 +73,27 @@ Kubernetes Model Context Protocol (MCP) server
|
74 | 73 | }
|
75 | 74 | defer mcpServer.Close()
|
76 | 75 |
|
77 |
| - var sseServer *server.SSEServer |
78 |
| - if ssePort := viper.GetInt("sse-port"); ssePort > 0 { |
79 |
| - sseServer = mcpServer.ServeSse(viper.GetString("sse-base-url")) |
| 76 | + ssePort := viper.GetInt("sse-port") |
| 77 | + if ssePort > 0 { |
| 78 | + sseServer := mcpServer.ServeSse(viper.GetString("sse-base-url")) |
80 | 79 | defer func() { _ = sseServer.Shutdown(cmd.Context()) }()
|
81 |
| - klog.V(0).Infof("SSE server starting on port %d", ssePort) |
| 80 | + klog.V(0).Infof("SSE server starting on port %d and path /sse", ssePort) |
82 | 81 | if err := sseServer.Start(fmt.Sprintf(":%d", ssePort)); err != nil {
|
83 | 82 | klog.Errorf("Failed to start SSE server: %s", err)
|
84 | 83 | return
|
85 | 84 | }
|
86 | 85 | }
|
| 86 | + |
| 87 | + httpPort := viper.GetInt("http-port") |
| 88 | + if httpPort > 0 { |
| 89 | + httpServer := mcpServer.ServeHTTP() |
| 90 | + klog.V(0).Infof("Streaming HTTP server starting on port %d and path /mcp", httpPort) |
| 91 | + if err := httpServer.Start(fmt.Sprintf(":%d", httpPort)); err != nil { |
| 92 | + klog.Errorf("Failed to start streaming HTTP server: %s", err) |
| 93 | + return |
| 94 | + } |
| 95 | + } |
| 96 | + |
87 | 97 | if err := mcpServer.ServeStdio(); err != nil && !errors.Is(err, context.Canceled) {
|
88 | 98 | panic(err)
|
89 | 99 | }
|
@@ -115,6 +125,7 @@ func flagInit() {
|
115 | 125 | rootCmd.Flags().BoolP("version", "v", false, "Print version information and quit")
|
116 | 126 | rootCmd.Flags().IntP("log-level", "", 0, "Set the log level (from 0 to 9)")
|
117 | 127 | rootCmd.Flags().IntP("sse-port", "", 0, "Start a SSE server on the specified port")
|
| 128 | + rootCmd.Flags().IntP("http-port", "", 0, "Start a streamable HTTP server on the specified port") |
118 | 129 | rootCmd.Flags().StringP("sse-base-url", "", "", "SSE public base URL to use when sending the endpoint message (e.g. https://example.com)")
|
119 | 130 | rootCmd.Flags().StringP("kubeconfig", "", "", "Path to the kubeconfig file to use for authentication")
|
120 | 131 | rootCmd.Flags().String("profile", "full", "MCP profile to use (one of: "+strings.Join(mcp.ProfileNames, ", ")+")")
|
|
0 commit comments