5
5
"fmt"
6
6
"os"
7
7
"strings"
8
+ "time"
8
9
9
10
"github.com/github/github-mcp-server/internal/ghmcp"
10
11
"github.com/github/github-mcp-server/pkg/github"
84
85
return fmt .Errorf ("failed to unmarshal toolsets: %w" , err )
85
86
}
86
87
88
+ // Pre-compute heartbeat interval
89
+ hbInterval , _ := time .ParseDuration (viper .GetString ("http_heartbeat_interval" ))
90
+
87
91
httpServerConfig := ghmcp.HttpServerConfig {
88
92
Version : version ,
89
93
Host : viper .GetString ("host" ),
@@ -101,6 +105,7 @@ var (
101
105
AppPrivateKey : appPrivateKey ,
102
106
EnableGitHubAppAuth : enableGitHubAppAuth ,
103
107
InstallationIDHeader : viper .GetString ("installation_id_header" ),
108
+ HeartbeatInterval : hbInterval ,
104
109
}
105
110
106
111
return ghmcp .RunHTTPServer (httpServerConfig )
@@ -133,6 +138,7 @@ func init() {
133
138
httpCmd .Flags ().String ("http-address" , ":8080" , "HTTP server address to bind to" )
134
139
httpCmd .Flags ().String ("http-mcp-path" , "/mcp" , "HTTP path for MCP endpoint" )
135
140
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)" )
136
142
137
143
// Bind flags to viper
138
144
_ = viper .BindPFlag ("toolsets" , rootCmd .PersistentFlags ().Lookup ("toolsets" ))
@@ -149,6 +155,7 @@ func init() {
149
155
_ = viper .BindPFlag ("http_address" , httpCmd .Flags ().Lookup ("http-address" ))
150
156
_ = viper .BindPFlag ("http_mcp_path" , httpCmd .Flags ().Lookup ("http-mcp-path" ))
151
157
_ = viper .BindPFlag ("http_enable_cors" , httpCmd .Flags ().Lookup ("http-enable-cors" ))
158
+ _ = viper .BindPFlag ("http_heartbeat_interval" , httpCmd .Flags ().Lookup ("http-heartbeat-interval" ))
152
159
153
160
// Add subcommands
154
161
rootCmd .AddCommand (stdioCmd )
0 commit comments