Skip to content

Commit b3781a2

Browse files
take env var and use the With rather than assignment
1 parent eb6c7f5 commit b3781a2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cmd/github-mcp-server/main.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportT
102102
logger.Fatal("GITHUB_PERSONAL_ACCESS_TOKEN not set")
103103
}
104104
ghClient := gogithub.NewClient(nil).WithAuthToken(token)
105-
if host := viper.GetString("gh-host"); host != "" {
105+
106+
// Check GH_HOST env var first, then fall back to viper config
107+
host := os.Getenv("GH_HOST")
108+
if host == "" {
109+
host = viper.GetString("gh-host")
110+
}
111+
112+
if host != "" {
106113
parsedURL, err := url.Parse(fmt.Sprintf("https://api.%s/", host))
107114
if err != nil {
108115
return fmt.Errorf("failed to parse provided GitHub host URL: %w", err)
@@ -113,8 +120,10 @@ func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportT
113120
return fmt.Errorf("failed to parse provided GitHub host URL: %w", err)
114121
}
115122

116-
ghClient.BaseURL = parsedURL
117-
ghClient.UploadURL = uploadURL
123+
ghClient, err = ghClient.WithEnterpriseURLs(parsedURL.String(), uploadURL.String())
124+
if err != nil {
125+
return fmt.Errorf("failed to create GitHub client with host: %w", err)
126+
}
118127
}
119128

120129
t, dumpTranslations := translations.TranslationHelper()

0 commit comments

Comments
 (0)