Skip to content

GitHub MCP Authentication Fails Despite Valid PAT #14162

Description

@EEbrami

What happened?

The Gemini CLI's GitHub Model Context Protocol (MCP) server fails to authenticate, consistently returning an OAuth error (Failed to fetch authorization server metadata for client registration) even when a valid Personal Access Token (PAT) is present in the .env file as GITHUB_MCP_PAT.

What did you expect to happen?

I expected the GitHub MCP server to authenticate successfully using the GITHUB_MCP_PAT provided in the .env file. The gemini extension.json and server.json configurations for the GitHub extension clearly
indicate that authentication should occur via an Authorization: Bearer $GITHUB_MCP_PAT header, bypassing any OAuth flow.

Steps to reproduce:

  1. Ensure a valid GITHUB_MCP_PAT is set in the .gemini/.env file (e.g., GITHUB_MCP_PAT=ghp_YOUR_VALID_TOKEN).
  2. Start the Gemini CLI.
  3. Attempt to authenticate the GitHub MCP using /mcp auth github.

Observed behavior:
The command fails with the following output:

1 ✕ Error during discovery for server 'github': 401 error received for SSE server 'github' without OAuth configuration. Please authenticate using: /mcp auth github
2
3 ℹ Starting OAuth authentication for MCP server 'github'...
4 ✕ Failed to authenticate with MCP server 'github': Failed to fetch authorization server metadata for client registration (attempted issuers: https://github.com, https://github.com/login)
The PAT itself was confirmed to be valid by a direct curl command:

1 curl -H "Authorization: token <YOUR_PAT>" https://api.github.com/user
This command successfully returned user profile data, proving the token's validity and necessary scopes.

Client information

  • CLI Version: 0.18.4
  • Git Commit: 2e8d783
  • Session ID: 77fdea42-5feb-44e3-8034-6c23b10c11ac
  • Operating System: darwin v25.2.1
  • Sandbox Environment: no sandbox
  • Model Version: auto
  • Memory Usage: 323.0 MB

Login information

I am attempting to authenticate the GitHub MCP using a Personal Access Token (PAT) stored as GITHUB_MCP_PAT in the .gemini/.env file.

Anything else we need to know?

The gemini-extension.json and server.json for the GitHub extension (extensions/github/) explicitly configure authentication via an Authorization: Bearer $GITHUB_MCP_PAT header to
https://api.githubcopilot.com/mcp/. However, the CLI appears to be initiating a standard OAuth flow (looking for https://github.com and https://github.com/login for metadata) instead of utilizing the
configured PAT. This suggests a disconnect between the extension's specified authentication method and the CLI's authentication handling for MCPs. The PAT's validity has been verified independently.

Metadata

Metadata

Assignees

Type

Projects

Status
Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions