@@ -188,149 +188,24 @@ To keep your GitHub PAT secure and reusable across different MCP hosts:
188188
189189### OAuth Authentication (stdio mode)
190190
191- For stdio mode (local binary execution) , you can use OAuth 2.1 with PKCE instead of a Personal Access Token. This provides an interactive browser-based login flow.
191+ For stdio mode, you can use OAuth 2.1 instead of a Personal Access Token. The server automatically selects the appropriate flow:
192192
193- ** The OAuth flow automatically adapts to your environment:**
194- - ** Native binary** : Uses interactive PKCE flow (browser opens automatically)
195- - ** Docker container** : Uses device flow (displays code + URL, no callback needed)
196- - ** Docker with port binding** : Can use PKCE flow with ` --oauth-callback-port `
193+ | Environment | Flow | Setup |
194+ | -------------| ------| -------|
195+ | Native binary | PKCE (browser auto-opens) | Just set ` GITHUB_OAUTH_CLIENT_ID ` |
196+ | Docker | Device flow (enter code at github.com/login/device) | Just set ` GITHUB_OAUTH_CLIENT_ID ` |
197+ | Docker with port | PKCE (browser auto-opens) | Set ` GITHUB_OAUTH_CALLBACK_PORT ` and bind port |
197198
198- #### Quick Setup
199-
200- ** Option 1: Device Flow (Easiest for Docker)**
201- ``` bash
202- # 1. Create GitHub OAuth App at https://github.com/settings/developers
203- # 2. Run with Docker (device flow automatic)
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
208- # → Displays: Visit https://github.com/login/device and enter code: ABCD-1234
209- ```
210-
211- ** Option 2: Interactive Flow (Best UX)**
199+ ** Quick start:**
212200``` bash
213- # For native binary
214201export GITHUB_OAUTH_CLIENT_ID=your_client_id
215202export GITHUB_OAUTH_CLIENT_SECRET=your_client_secret
216203./github-mcp-server stdio
217- # → Browser opens automatically
218-
219- # For Docker with port binding (requires setup in OAuth app callback)
220- docker run -i --rm -p 8080:8080 \
221- -e GITHUB_OAUTH_CLIENT_ID=your_client_id \
222- -e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
223- -e GITHUB_OAUTH_CALLBACK_PORT=8080 \
224- ghcr.io/github/github-mcp-server
225- # → Browser opens automatically (callback works via bound port)
226- ```
227-
228- #### Prerequisites for OAuth
229-
230- 1 . Create a GitHub OAuth App at [ https://github.com/settings/developers ] ( https://github.com/settings/developers )
231- - For native binary: Set callback URL to ` http://localhost ` (port is dynamic)
232- - For Docker with port binding: Set callback URL to ` http://localhost:PORT/callback ` (your chosen port)
233- - For Docker with device flow: No callback URL needed
234-
235- 2 . Set your OAuth app credentials:
236- ``` bash
237- export GITHUB_OAUTH_CLIENT_ID=your_client_id
238- export GITHUB_OAUTH_CLIENT_SECRET=your_client_secret
239- ```
240-
241- 3 . Run the server without a PAT:
242- ``` bash
243- # Native binary - interactive PKCE flow
244- ./github-mcp-server stdio
245-
246- # Docker - device flow (automatic)
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
251-
252- # Docker with port binding - interactive PKCE flow
253- docker run -i --rm -p 8080:8080 \
254- -e GITHUB_OAUTH_CLIENT_ID=your_client_id \
255- -e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
256- -e GITHUB_OAUTH_CALLBACK_PORT=8080 \
257- ghcr.io/github/github-mcp-server
258- ```
259-
260- The server will automatically detect the environment and use the appropriate OAuth flow.
261-
262- #### OAuth Configuration Options
263-
264- - ` --oauth-client-id ` / ` GITHUB_OAUTH_CLIENT_ID ` - Your GitHub OAuth app client ID (required for OAuth flow)
265- - ` --oauth-client-secret ` / ` GITHUB_OAUTH_CLIENT_SECRET ` - Your GitHub OAuth app client secret (required)
266- - ` --oauth-scopes ` / ` GITHUB_OAUTH_SCOPES ` - Comma-separated list of scopes (defaults: ` repo,user,gist,notifications,read:org,project ` )
267- - ` --oauth-callback-port ` / ` GITHUB_OAUTH_CALLBACK_PORT ` - Fixed callback port for Docker (0 for random)
268-
269- Example with custom scopes:
270- ``` bash
271- ./github-mcp-server stdio \
272- --oauth-client-id YOUR_CLIENT_ID \
273- --oauth-client-secret YOUR_CLIENT_SECRET \
274- --oauth-scopes repo,user
275204```
276205
277- #### Pre-configured MCP Host Setup
278-
279- OAuth can be pre-configured for MCP hosts (similar to PAT distribution). For Docker with port binding:
280-
281- ** Claude Desktop/Code:**
282- ``` bash
283- claude mcp add github \
284- -e GITHUB_OAUTH_CLIENT_ID=your_client_id \
285- -e GITHUB_OAUTH_CLIENT_SECRET=your_client_secret \
286- -e GITHUB_OAUTH_CALLBACK_PORT=8080 \
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
292- ```
293-
294- ** VS Code (settings.json):**
295- ``` json
296- {
297- "mcp" : {
298- "servers" : {
299- "github" : {
300- "command" : " docker" ,
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" ],
306- "env" : {
307- "GITHUB_OAUTH_CLIENT_ID" : " ${input:github_oauth_client_id}" ,
308- "GITHUB_OAUTH_CLIENT_SECRET" : " ${input:github_oauth_client_secret}" ,
309- "GITHUB_OAUTH_CALLBACK_PORT" : " 8080"
310- }
311- }
312- }
313- }
314- }
315- ```
316-
317- Port binding setup is straightforward and can be automated through installation instructions.
318-
319- #### Device Flow vs Interactive Flow
320-
321- ** Device Flow** (automatic in Docker):
322- - Displays a verification URL and code
323- - User visits URL in browser and enters code
324- - No callback server required
325- - Works in any environment
326-
327- ** Interactive PKCE Flow** (automatic for native binary):
328- - Opens browser automatically
329- - User approves scopes
330- - Faster and more seamless
331- - Requires callback server (localhost)
206+ See [ docs/oauth-authentication.md] ( docs/oauth-authentication.md ) for full setup instructions, including how to create a GitHub OAuth App.
332207
333- > ** Note** : OAuth authentication is only available in stdio mode. For remote server usage, use Personal Access Tokens as described above .
208+ > ** Note** : OAuth is only available in stdio mode. For remote server usage, use Personal Access Tokens.
334209
335210### GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com)
336211
0 commit comments