@@ -13,6 +13,7 @@ import (
1313iolog"github.com/github/github-mcp-server/pkg/log"
1414"github.com/github/github-mcp-server/pkg/translations"
1515gogithub"github.com/google/go-github/v69/github"
16+ "github.com/mark3labs/mcp-go/mcp"
1617"github.com/mark3labs/mcp-go/server"
1718log"github.com/sirupsen/logrus"
1819"github.com/spf13/cobra"
@@ -137,11 +138,19 @@ func runStdioServer(cfg runConfig) error {
137138
138139t ,dumpTranslations := translations .TranslationHelper ()
139140
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+
140145getClient := func (_ context.Context ) (* gogithub.Client ,error ) {
141146return ghClient ,nil // closing over client
142147}
148+
149+ hooks := & server.Hooks {
150+ OnBeforeInitialize : []server.OnBeforeInitializeFunc {beforeInit },
151+ }
143152// Create
144- ghServer := github .NewServer (getClient ,version ,cfg .readOnly ,t )
153+ ghServer := github .NewServer (getClient ,version ,cfg .readOnly ,t , server . WithHooks ( hooks ) )
145154stdioServer := server .NewStdioServer (ghServer )
146155
147156stdLogger := stdlog .New (cfg .logger .Writer (),"stdioserver" ,0 )