Skip to content

Commit cf5ee86

Browse files
rudimentary enterprise support
1 parent fca7cd7 commit cf5ee86

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"
@@ -49,10 +50,12 @@ func init() {
4950
// Add global flags that will be shared by all commands
5051
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")
5152
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
53+
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
5254

5355
// Bind flag to viper
5456
viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
5557
viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
58+
viper.BindPFlag("gh-host", rootCmd.PersistentFlags().Lookup("gh-host"))
5659

5760
// Add subcommands
5861
rootCmd.AddCommand(stdioCmd)
@@ -92,6 +95,20 @@ func runStdioServer(logger *log.Logger, logCommands bool) error {
9295
logger.Fatal("GITHUB_PERSONAL_ACCESS_TOKEN not set")
9396
}
9497
ghClient := gogithub.NewClient(nil).WithAuthToken(token)
98+
if host := viper.GetString("gh-host"); host != "" {
99+
url, err := url.Parse(fmt.Sprintf("https://api.%s/", host))
100+
if err != nil {
101+
return fmt.Errorf("failed to parse provided GitHub host URL: %w", err)
102+
}
103+
104+
uploadUrl, err := url.Parse(fmt.Sprintf("https://uploads.%s/", host))
105+
if err != nil {
106+
return fmt.Errorf("failed to parse provided GitHub host URL: %w", err)
107+
}
108+
109+
ghClient.BaseURL = url
110+
ghClient.UploadURL = uploadUrl
111+
}
95112

96113
// Create server
97114
ghServer := github.NewServer(ghClient)

0 commit comments

Comments
 (0)