@@ -13,6 +13,7 @@ import (
13
13
iolog"github.com/github/github-mcp-server/pkg/log"
14
14
"github.com/github/github-mcp-server/pkg/translations"
15
15
gogithub"github.com/google/go-github/v69/github"
16
+ "github.com/mark3labs/mcp-go/mcp"
16
17
"github.com/mark3labs/mcp-go/server"
17
18
log"github.com/sirupsen/logrus"
18
19
"github.com/spf13/cobra"
@@ -137,11 +138,19 @@ func runStdioServer(cfg runConfig) error {
137
138
138
139
t ,dumpTranslations := translations .TranslationHelper ()
139
140
141
+ beforeInit := func (_ context.Context ,_ any ,message * mcp.InitializeRequest ) {
142
+ ghClient .UserAgent = fmt .Sprintf ("github-mcp-server/%s (%s/%s)" ,version ,message .Params .ClientInfo .Name ,message .Params .ClientInfo .Version )
143
+ }
144
+
140
145
getClient := func (_ context.Context ) (* gogithub.Client ,error ) {
141
146
return ghClient ,nil // closing over client
142
147
}
148
+
149
+ hooks := & server.Hooks {
150
+ OnBeforeInitialize : []server.OnBeforeInitializeFunc {beforeInit },
151
+ }
143
152
// Create
144
- ghServer := github .NewServer (getClient ,version ,cfg .readOnly ,t )
153
+ ghServer := github .NewServer (getClient ,version ,cfg .readOnly ,t , server . WithHooks ( hooks ) )
145
154
stdioServer := server .NewStdioServer (ghServer )
146
155
147
156
stdLogger := stdlog .New (cfg .logger .Writer (),"stdioserver" ,0 )