Skip to content

Commit b7b1073

Browse files
authored
Apply remaining changes
1 parent 1add5fe commit b7b1073

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ the hostname for GitHub Enterprise Server or GitHub Enterprise Cloud with data r
246246

247247
- For GitHub Enterprise Server, prefix the hostname with the `https://` URI scheme, as it otherwise defaults to `http://`, which GitHub Enterprise Server does not support.
248248
- For GitHub Enterprise Cloud with data residency, use `https://YOURSUBDOMAIN.ghe.com` as the hostname.
249+
- If your OAuth authorization server is different from `<host>/login/oauth`, set `--authorization-server` or `GITHUB_AUTHORIZATION_SERVER`.
249250

250251
``` json
251252
"github": {

cmd/github-mcp-server/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ var (
139139
Host: viper.GetString("host"),
140140
Port: viper.GetInt("port"),
141141
BaseURL: viper.GetString("base-url"),
142+
AuthorizationServer: viper.GetString("authorization-server"),
142143
ResourcePath: viper.GetString("base-path"),
143144
ExportTranslations: viper.GetBool("export-translations"),
144145
EnableCommandLogging: viper.GetBool("enable-command-logging"),
@@ -184,6 +185,7 @@ func init() {
184185
// HTTP-specific flags
185186
httpCmd.Flags().Int("port", 8082, "HTTP server port")
186187
httpCmd.Flags().String("base-url", "", "Base URL where this server is publicly accessible (for OAuth resource metadata)")
188+
httpCmd.Flags().String("authorization-server", "", "OAuth authorization server URL override (for OAuth resource metadata)")
187189
httpCmd.Flags().String("base-path", "", "Externally visible base path for the HTTP server (for OAuth resource metadata)")
188190
httpCmd.Flags().Bool("scope-challenge", false, "Enable OAuth scope challenge responses")
189191

@@ -203,6 +205,7 @@ func init() {
203205
_ = viper.BindPFlag("repo-access-cache-ttl", rootCmd.PersistentFlags().Lookup("repo-access-cache-ttl"))
204206
_ = viper.BindPFlag("port", httpCmd.Flags().Lookup("port"))
205207
_ = viper.BindPFlag("base-url", httpCmd.Flags().Lookup("base-url"))
208+
_ = viper.BindPFlag("authorization-server", httpCmd.Flags().Lookup("authorization-server"))
206209
_ = viper.BindPFlag("base-path", httpCmd.Flags().Lookup("base-path"))
207210
_ = viper.BindPFlag("scope-challenge", httpCmd.Flags().Lookup("scope-challenge"))
208211
// Add subcommands

docs/streamable-http.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ The OAuth protected resource metadata's `resource` attribute will be populated w
5959

6060
This allows OAuth clients to discover authentication requirements and endpoint information automatically.
6161

62+
### With Custom OAuth Authorization Server
63+
64+
If your GHES deployment requires a non-default OAuth authorization server URL, override it explicitly:
65+
66+
```bash
67+
github-mcp-server http --gh-host https://ghe.example.com --authorization-server https://auth.ghe.example.com/login/oauth
68+
```
69+
70+
You can also set this via `GITHUB_AUTHORIZATION_SERVER`.
71+
6272
## Client Configuration
6373

6474
### Using OAuth Authentication

pkg/http/server.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ type ServerConfig struct {
3939
// If not set, the server will derive the URL from incoming request headers.
4040
BaseURL string
4141

42+
// AuthorizationServer is the OAuth authorization server URL advertised in OAuth
43+
// protected resource metadata. If empty, it is derived from the GitHub host.
44+
AuthorizationServer string
45+
4246
// ResourcePath is the externally visible base path for this server (e.g., "/mcp").
4347
// This is used to restore the original path when a proxy strips a base path before forwarding.
4448
ResourcePath string
@@ -150,8 +154,9 @@ func RunHTTPServer(cfg ServerConfig) error {
150154

151155
// Register OAuth protected resource metadata endpoints
152156
oauthCfg := &oauth.Config{
153-
BaseURL: cfg.BaseURL,
154-
ResourcePath: cfg.ResourcePath,
157+
BaseURL: cfg.BaseURL,
158+
AuthorizationServer: cfg.AuthorizationServer,
159+
ResourcePath: cfg.ResourcePath,
155160
}
156161

157162
serverOptions := []HandlerOption{}

0 commit comments

Comments
 (0)