@@ -74,14 +74,19 @@ func createGitHubClients(cfg github.MCPServerConfig, apiHost utils.APIHostResolv
7474 Transport : baseTransport ,
7575 Agent : fmt .Sprintf ("github-mcp-server/%s" , cfg .Version ),
7676 }
77- restClientOpts := []gogithub.Option {
78- gogithub .WithHTTPClient (& http.Client {Transport : restUATransport }),
79- gogithub .WithEnterpriseURLs (restURL .String (), uploadURL .String ()),
80- }
81- if authTransport == nil {
82- restClientOpts = append (restClientOpts , gogithub .WithAuthToken (cfg .Token ))
77+ var restClient * gogithub.Client
78+ if authTransport != nil {
79+ restClient , err = gogithub .NewClient (
80+ gogithub .WithHTTPClient (& http.Client {Transport : restUATransport }),
81+ gogithub .WithEnterpriseURLs (restURL .String (), uploadURL .String ()),
82+ )
83+ } else {
84+ restClient , err = gogithub .NewClient (
85+ gogithub .WithHTTPClient (& http.Client {Transport : restUATransport }),
86+ gogithub .WithAuthToken (cfg .Token ),
87+ gogithub .WithEnterpriseURLs (restURL .String (), uploadURL .String ()),
88+ )
8389 }
84- restClient , err := gogithub .NewClient (restClientOpts ... )
8590 if err != nil {
8691 return nil , fmt .Errorf ("failed to create REST client: %w" , err )
8792 }
0 commit comments