Skip to content

Commit eb6c7f5

Browse files
rudimentary enterprise support
1 parent bc3bc76 commit eb6c7f5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cmd/github-mcp-server/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
stdlog "log"
8+
"net/url"
89
"os"
910
"os/signal"
1011
"syscall"
@@ -54,12 +55,14 @@ func init() {
5455
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")
5556
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
5657
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
58+
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
5759

5860
// Bind flag to viper
5961
viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
6062
viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
6163
viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
6264
viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
65+
viper.BindPFlag("gh-host", rootCmd.PersistentFlags().Lookup("gh-host"))
6366

6467
// Add subcommands
6568
rootCmd.AddCommand(stdioCmd)
@@ -99,6 +102,20 @@ func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportT
99102
logger.Fatal("GITHUB_PERSONAL_ACCESS_TOKEN not set")
100103
}
101104
ghClient := gogithub.NewClient(nil).WithAuthToken(token)
105+
if host := viper.GetString("gh-host"); host != "" {
106+
parsedURL, err := url.Parse(fmt.Sprintf("https://api.%s/", host))
107+
if err != nil {
108+
return fmt.Errorf("failed to parse provided GitHub host URL: %w", err)
109+
}
110+
111+
uploadURL, err := url.Parse(fmt.Sprintf("https://uploads.%s/", host))
112+
if err != nil {
113+
return fmt.Errorf("failed to parse provided GitHub host URL: %w", err)
114+
}
115+
116+
ghClient.BaseURL = parsedURL
117+
ghClient.UploadURL = uploadURL
118+
}
102119

103120
t, dumpTranslations := translations.TranslationHelper()
104121

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy