Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ and set it as the GITHUB_PERSONAL_ACCESS_TOKEN environment variable.
- `pull_number`: Pull request number (number, required)

- **get_pull_request_reviews** - Get the reviews on a pull request

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
Expand Down Expand Up @@ -375,7 +376,7 @@ Run **Preferences: Open User Settings (JSON)**, and create or append to the `mcp
"args": ["stdio"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:githubpat}"
},
}
}
}
}
Expand All @@ -391,6 +392,10 @@ Try something like the following prompt to verify that it works:
I'd like to know more about my GitHub profile.
```

## GitHub Enterprise Server

The flag `--gh-host` and the environment variable `GH_HOST` can be used to set the GitHub Enterprise Server hostname.

## TODO

Testing
Expand Down
16 changes: 16 additions & 0 deletions cmd/github-mcp-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ func init() {
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")

// Bind flag to viper
viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
viper.BindPFlag("gh-host", rootCmd.PersistentFlags().Lookup("gh-host"))

// Add subcommands
rootCmd.AddCommand(stdioCmd)
Expand Down Expand Up @@ -100,6 +102,20 @@ func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportT
}
ghClient := gogithub.NewClient(nil).WithAuthToken(token)

// Check GH_HOST env var first, then fall back to viper config
host := os.Getenv("GH_HOST")
if host == "" {
host = viper.GetString("gh-host")
}

if host != "" {
var err error
ghClient, err = ghClient.WithEnterpriseURLs(host, host)
if err != nil {
return fmt.Errorf("failed to create GitHub client with host: %w", err)
}
}

t, dumpTranslations := translations.TranslationHelper()

// Create
Expand Down