Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf5ee86

Browse files
rudimentary enterprise support
1 parentfca7cd7 commitcf5ee86

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+
ifhost:=viper.GetString("gh-host");host!="" {
99+
url,err:=url.Parse(fmt.Sprintf("https://api.%s/",host))
100+
iferr!=nil {
101+
returnfmt.Errorf("failed to parse provided GitHub host URL: %w",err)
102+
}
103+
104+
uploadUrl,err:=url.Parse(fmt.Sprintf("https://uploads.%s/",host))
105+
iferr!=nil {
106+
returnfmt.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)

[8]ページ先頭

©2009-2025 Movatter.jp