55 "fmt"
66 "github.com/manusa/kubernetes-mcp-server/pkg/mcp"
77 "github.com/manusa/kubernetes-mcp-server/pkg/version"
8+ "github.com/mark3labs/mcp-go/server"
89 "github.com/spf13/cobra"
910 "github.com/spf13/viper"
1011 "golang.org/x/net/context"
@@ -22,6 +23,15 @@ Kubernetes Model Context Protocol (MCP) server
2223 # shows version information
2324 kubernetes-mcp-server --version
2425
26+ # start STDIO server
27+ kubernetes-mcp-server
28+
29+ # start a SSE server on port 8080
30+ kubernetes-mcp-server --sse-port 8080
31+
32+ # start a SSE server on port 8080 with a public host of example.com
33+ kubernetes-mcp-server --sse-port 8080 --sse-public-host example.com
34+
2535 # TODO: add more examples` ,
2636 Run : func (cmd * cobra.Command , args []string ) {
2737 if viper .GetBool ("version" ) {
@@ -32,14 +42,27 @@ Kubernetes Model Context Protocol (MCP) server
3242 if err != nil {
3343 panic (err )
3444 }
45+
46+ var sseServer * server.SSEServer
47+ if ssePort := viper .GetInt ("sse-port" ); ssePort > 0 {
48+ sseServer = mcpServer .ServeSse (viper .GetString ("sse-public-host" ), ssePort )
49+ if err := sseServer .Start (fmt .Sprintf (":%d" , ssePort )); err != nil {
50+ panic (err )
51+ }
52+ }
3553 if err := mcpServer .ServeStdio (); err != nil && ! errors .Is (err , context .Canceled ) {
3654 panic (err )
3755 }
56+ if sseServer != nil {
57+ _ = sseServer .Shutdown (cmd .Context ())
58+ }
3859 },
3960}
4061
4162func init () {
4263 rootCmd .Flags ().BoolP ("version" , "v" , false , "Print version information and quit" )
64+ rootCmd .Flags ().IntP ("sse-port" , "" , 0 , "Start a SSE server on the specified port" )
65+ rootCmd .Flags ().StringP ("sse-public-host" , "" , "localhost" , "SSE Public host to use in the server" )
4366 _ = viper .BindPFlags (rootCmd .Flags ())
4467}
4568
0 commit comments