55 "fmt"
66 "os"
77 "strings"
8+ "time"
89
910 "github.com/github/github-mcp-server/internal/ghmcp"
1011 "github.com/github/github-mcp-server/pkg/github"
8485 return fmt .Errorf ("failed to unmarshal toolsets: %w" , err )
8586 }
8687
88+ // Pre-compute heartbeat interval
89+ hbInterval , _ := time .ParseDuration (viper .GetString ("http_heartbeat_interval" ))
90+
8791 httpServerConfig := ghmcp.HttpServerConfig {
8892 Version : version ,
8993 Host : viper .GetString ("host" ),
@@ -101,6 +105,7 @@ var (
101105 AppPrivateKey : appPrivateKey ,
102106 EnableGitHubAppAuth : enableGitHubAppAuth ,
103107 InstallationIDHeader : viper .GetString ("installation_id_header" ),
108+ HeartbeatInterval : hbInterval ,
104109 }
105110
106111 return ghmcp .RunHTTPServer (httpServerConfig )
@@ -133,6 +138,7 @@ func init() {
133138 httpCmd .Flags ().String ("http-address" , ":8080" , "HTTP server address to bind to" )
134139 httpCmd .Flags ().String ("http-mcp-path" , "/mcp" , "HTTP path for MCP endpoint" )
135140 httpCmd .Flags ().Bool ("http-enable-cors" , false , "Enable CORS for cross-origin requests" )
141+ httpCmd .Flags ().String ("http-heartbeat-interval" , "15s" , "Interval for SSE heartbeats on GET listener (e.g., 15s; set 0 to disable)" )
136142
137143 // Bind flags to viper
138144 _ = viper .BindPFlag ("toolsets" , rootCmd .PersistentFlags ().Lookup ("toolsets" ))
@@ -149,6 +155,7 @@ func init() {
149155 _ = viper .BindPFlag ("http_address" , httpCmd .Flags ().Lookup ("http-address" ))
150156 _ = viper .BindPFlag ("http_mcp_path" , httpCmd .Flags ().Lookup ("http-mcp-path" ))
151157 _ = viper .BindPFlag ("http_enable_cors" , httpCmd .Flags ().Lookup ("http-enable-cors" ))
158+ _ = viper .BindPFlag ("http_heartbeat_interval" , httpCmd .Flags ().Lookup ("http-heartbeat-interval" ))
152159
153160 // Add subcommands
154161 rootCmd .AddCommand (stdioCmd )
0 commit comments