Skip to content

Commit 76defa8

Browse files
Update OAuth examples to always include client secret
- Remove "optional" language for client secret - Add client secret to all code examples - Update CLI flag description to say "recommended" - Update code comment from "Optional" to "Recommended" - Align with best practice that GitHub OAuth apps should provide both ID and secret Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
1 parent 3278eee commit 76defa8

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,25 @@ For stdio mode (local binary execution), you can use OAuth 2.1 with PKCE instead
201201
```bash
202202
# 1. Create GitHub OAuth App at https://github.com/settings/developers
203203
# 2. Run with Docker (device flow automatic)
204-
docker run -i --rm -e GITHUB_OAUTH_CLIENT_ID=your_client_id ghcr.io/github/github-mcp-server
204+
docker run -i --rm \
205+
-e GITHUB_OAUTH_CLIENT_ID=your_client_id \
206+
-e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
207+
ghcr.io/github/github-mcp-server
205208
# → Displays: Visit https://github.com/login/device and enter code: ABCD-1234
206209
```
207210

208211
**Option 2: Interactive Flow (Best UX)**
209212
```bash
210213
# For native binary
211214
export GITHUB_OAUTH_CLIENT_ID=your_client_id
215+
export GITHUB_OAUTH_CLIENT_SECRET=your_client_secret
212216
./github-mcp-server stdio
213217
# → Browser opens automatically
214218

215219
# For Docker with port binding (requires setup in OAuth app callback)
216220
docker run -i --rm -p 8080:8080 \
217221
-e GITHUB_OAUTH_CLIENT_ID=your_client_id \
222+
-e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
218223
-e GITHUB_OAUTH_CALLBACK_PORT=8080 \
219224
ghcr.io/github/github-mcp-server
220225
# → Browser opens automatically (callback works via bound port)
@@ -226,12 +231,11 @@ docker run -i --rm -p 8080:8080 \
226231
- For native binary: Set callback URL to `http://localhost` (port is dynamic)
227232
- For Docker with port binding: Set callback URL to `http://localhost:PORT/callback` (your chosen port)
228233
- For Docker with device flow: No callback URL needed
229-
- For public clients, you can use PKCE without a client secret
230234

231235
2. Set your OAuth app credentials:
232236
```bash
233237
export GITHUB_OAUTH_CLIENT_ID=your_client_id
234-
export GITHUB_OAUTH_CLIENT_SECRET=your_client_secret # Optional for public clients with PKCE
238+
export GITHUB_OAUTH_CLIENT_SECRET=your_client_secret
235239
```
236240

237241
3. Run the server without a PAT:
@@ -240,11 +244,15 @@ docker run -i --rm -p 8080:8080 \
240244
./github-mcp-server stdio
241245

242246
# Docker - device flow (automatic)
243-
docker run -i --rm -e GITHUB_OAUTH_CLIENT_ID=your_client_id ghcr.io/github/github-mcp-server
247+
docker run -i --rm \
248+
-e GITHUB_OAUTH_CLIENT_ID=your_client_id \
249+
-e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
250+
ghcr.io/github/github-mcp-server
244251

245252
# Docker with port binding - interactive PKCE flow
246253
docker run -i --rm -p 8080:8080 \
247254
-e GITHUB_OAUTH_CLIENT_ID=your_client_id \
255+
-e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
248256
-e GITHUB_OAUTH_CALLBACK_PORT=8080 \
249257
ghcr.io/github/github-mcp-server
250258
```
@@ -254,13 +262,16 @@ The server will automatically detect the environment and use the appropriate OAu
254262
#### OAuth Configuration Options
255263

256264
- `--oauth-client-id` / `GITHUB_OAUTH_CLIENT_ID` - Your GitHub OAuth app client ID (required for OAuth flow)
257-
- `--oauth-client-secret` / `GITHUB_OAUTH_CLIENT_SECRET` - Your client secret (optional, PKCE is used)
265+
- `--oauth-client-secret` / `GITHUB_OAUTH_CLIENT_SECRET` - Your GitHub OAuth app client secret (required)
258266
- `--oauth-scopes` / `GITHUB_OAUTH_SCOPES` - Comma-separated list of scopes (defaults: `repo,user,gist,notifications,read:org,project`)
259267
- `--oauth-callback-port` / `GITHUB_OAUTH_CALLBACK_PORT` - Fixed callback port for Docker (0 for random)
260268

261269
Example with custom scopes:
262270
```bash
263-
./github-mcp-server stdio --oauth-client-id YOUR_CLIENT_ID --oauth-scopes repo,user
271+
./github-mcp-server stdio \
272+
--oauth-client-id YOUR_CLIENT_ID \
273+
--oauth-client-secret YOUR_CLIENT_SECRET \
274+
--oauth-scopes repo,user
264275
```
265276

266277
#### Pre-configured MCP Host Setup
@@ -271,8 +282,13 @@ OAuth can be pre-configured for MCP hosts (similar to PAT distribution). For Doc
271282
```bash
272283
claude mcp add github \
273284
-e GITHUB_OAUTH_CLIENT_ID=your_client_id \
285+
-e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
274286
-e GITHUB_OAUTH_CALLBACK_PORT=8080 \
275-
-- docker run -i --rm -p 8080:8080 -e GITHUB_OAUTH_CLIENT_ID -e GITHUB_OAUTH_CALLBACK_PORT ghcr.io/github/github-mcp-server
287+
-- docker run -i --rm -p 8080:8080 \
288+
-e GITHUB_OAUTH_CLIENT_ID \
289+
-e GITHUB_OAUTH_CLIENT_SECRET \
290+
-e GITHUB_OAUTH_CALLBACK_PORT \
291+
ghcr.io/github/github-mcp-server
276292
```
277293

278294
**VS Code (settings.json):**
@@ -282,9 +298,14 @@ claude mcp add github \
282298
"servers": {
283299
"github": {
284300
"command": "docker",
285-
"args": ["run", "-i", "--rm", "-p", "8080:8080", "-e", "GITHUB_OAUTH_CLIENT_ID", "-e", "GITHUB_OAUTH_CALLBACK_PORT", "ghcr.io/github/github-mcp-server"],
301+
"args": ["run", "-i", "--rm", "-p", "8080:8080",
302+
"-e", "GITHUB_OAUTH_CLIENT_ID",
303+
"-e", "GITHUB_OAUTH_CLIENT_SECRET",
304+
"-e", "GITHUB_OAUTH_CALLBACK_PORT",
305+
"ghcr.io/github/github-mcp-server"],
286306
"env": {
287307
"GITHUB_OAUTH_CLIENT_ID": "${input:github_oauth_client_id}",
308+
"GITHUB_OAUTH_CLIENT_SECRET": "${input:github_oauth_client_secret}",
288309
"GITHUB_OAUTH_CALLBACK_PORT": "8080"
289310
}
290311
}

cmd/github-mcp-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func init() {
136136

137137
// OAuth flags (stdio mode only)
138138
rootCmd.PersistentFlags().String("oauth-client-id", "", "GitHub OAuth app client ID (enables interactive OAuth flow if token not set)")
139-
rootCmd.PersistentFlags().String("oauth-client-secret", "", "GitHub OAuth app client secret (optional for public clients with PKCE)")
139+
rootCmd.PersistentFlags().String("oauth-client-secret", "", "GitHub OAuth app client secret (recommended)")
140140
rootCmd.PersistentFlags().StringSlice("oauth-scopes", nil, "OAuth scopes to request (comma-separated)")
141141
rootCmd.PersistentFlags().Int("oauth-callback-port", 0, "Fixed port for OAuth callback (0 for random, required for Docker with -p flag)")
142142

internal/oauth/oauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
// Config holds the OAuth configuration
2727
type Config struct {
2828
ClientID string
29-
ClientSecret string // Optional for public clients with PKCE
29+
ClientSecret string // Recommended for GitHub OAuth apps
3030
RedirectURL string
3131
Scopes []string
3232
AuthURL string

0 commit comments

Comments
 (0)