mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

[Bug]: GitHub stuck in Pending Auth: static headers block the offered OAuth sign-in with HTTP 500

Open algis-dumbris opened this issue 2 weeks ago • 0 comments

What happened?

GitHub is stuck in Pending Auth. MCPProxy's tray and diagnostics offer Sign in, but clicking it immediately returns HTTP 500:

Couldn't sign in to github
HTTP 500: Failed to trigger login: failed to start OAuth: failed to start OAuth flow: OAuth is not supported or not required for server 'github'

This appears to be an inconsistency between automatic authentication fallback and manual-login eligibility: the connection path discovers OAuth after static-header authentication fails, while the manual-login path rejects that same server because headers are configured and oauth is null.

Expected behavior

A server put into Pending Auth by OAuth discovery should have a usable recovery action. Manual login should consistently account for the discovered authentication requirement. If an upstream configured for static-token authentication cannot use OAuth, report that clearly and offer credential repair instead of an unusable sign-in action and HTTP 500.

Steps to reproduce

Observed production sequence; not a fresh isolated reproduction:

  1. Configure the GitHub remote MCP server with a Bearer credential reference and no explicit OAuth block:

    {
      "name": "github",
      "url": "https://api.githubcopilot.com/mcp/",
      "protocol": "http",
      "headers": {"Authorization": "Bearer <secret-reference-redacted>"},
      "oauth": null,
      "enabled": true
    }
    
  2. The server connects successfully with headers. Later, initialization returns authorization required.

  3. The automatic connection fallback discovers OAuth metadata, finds no stored OAuth token, and parks the server in Pending Auth.

  4. Click Sign in for github in the tray.

  5. POST /api/v1/servers/github/login returns HTTP 500 in approximately 1–3 ms. Two attempts produce the same result; the failure occurs before a browser authorization round trip.

For a controlled regression test, have a mock HTTP MCP upstream reject static-header initialization with a genuine authentication challenge and advertise valid OAuth metadata. Check the offered manual-login action after it enters Pending Auth.

MCPProxy version / operating system

  • MCPProxy v0.73.0 (personal) darwin/arm64.
  • Both CLI version and daemon startup logs confirm v0.73.0.
  • macOS 26.5.2, build 25F84, Apple Silicon.
  • DMG installation, daemon launched by tray.
  • Enabled upstream; not quarantined.
  • Configuration timestamps: created 2026-08-14; last upstream updated timestamp 2026-08-14. These timestamps alone do not prove there were no runtime credential changes.
  • Source inspected at tag v0.73.0, commit f8b3c598263f4d5a2ac851819e21d8c9194ddec3.

Relevant logs / timeline

All timestamps below use the recorded local offset +02:00 (Europe/Vilnius).

Previously working connection

2026-11-11T10:42:08.639+02:00 Starting mcpproxy {version:v0.73.0, edition:personal}
2026-11-11T10:42:11.943+02:00 core/connection_http.go:199 MCP initialization completed successfully
  server=github
  server_name=github-mcp-server
  server_version=github-mcp-server/remote-e5e23c04485054844cab9fd143d37e7269df94a6
  protocol_version=2025-11-25

There were repeated DNS/timeout failures between November 11 and November 14 (lookup api.githubcopilot.com: no such host, i/o timeout, context deadline exceeded). These are preceding connectivity problems; they do not explain the later immediate manual-login rejection.

Transition into Pending Auth

2026-11-14T08:17:48.325+02:00 State transition: Error -> Connecting (github)
2026-11-14T08:17:48.951+02:00 core/connection_http.go:199 MCP initialize JSON-RPC call failed: transport error: authorization required
2026-11-14T08:17:49.107+02:00 core/connection_http.go:227 MCP initialize JSON-RPC call failed: transport error: authorization required
2026-11-14T08:17:49.477+02:00 Auto-detected resource parameter from Protected Resource Metadata (RFC 9728): https://api.githubcopilot.com/mcp/
2026-11-14T08:17:49.629+02:00 Auto-discovered OAuth scopes from Protected Resource Metadata
  metadata_url=https://api.githubcopilot.com/.well-known/oauth-protected-resource/mcp/
2026-11-14T08:17:49.631+02:00 OAuth callback server started: http://127.0.0.1:59493/oauth/callback
2026-11-14T08:17:49.788+02:00 Using discovered auth server URL: https://github.com/login/oauth
2026-11-14T08:17:50.055+02:00 Using validated OAuth metadata URL: https://github.com/.well-known/oauth-authorization-server/login/oauth
2026-11-14T08:17:50.055+02:00 No existing token found in persistent storage: no token available
2026-11-14T08:17:50.055+02:00 No persisted DCR credentials found - will attempt DCR or use public client mode
2026-11-14T08:17:50.056+02:00 OAuth config created successfully (PKCE enabled, public-client mode, persistent token store)
2026-11-14T08:17:50.058+02:00 core/connection_oauth.go:476 MCP initialize JSON-RPC call failed: no valid token available, authorization required
2026-11-14T08:17:50.059+02:00 OAuth authorization required during MCP init - deferring OAuth for background processing
2026-11-14T08:17:50.059+02:00 OAuth login available via Web UI, system tray menu, or CLI command
2026-11-14T08:17:50.060+02:00 State transition: Connecting -> Pending Auth (github)

Discovered scopes: repo read:org read:user user:email read:packages write:packages read:project project gist notifications; MCPProxy also added offline_access because it was advertised by the authorization server.

User sign-in fails before OAuth can start

2026-11-17T08:03:05.877+02:00 Starting quick OAuth flow (returns browser status immediately) {server:github}
2026-11-17T08:03:05.878+02:00 OAuth not applicable based on config {server:github}
2026-11-17T08:03:05.878+02:00 httpapi/server.go:883 Failed to trigger OAuth login
  error="failed to start OAuth: failed to start OAuth flow: OAuth is not supported or not required for server 'github'"
2026-11-17T08:03:05.879+02:00 POST /api/v1/servers/github/login status=500 duration=0.003014875

2026-11-17T08:03:59.863+02:00 Starting quick OAuth flow (returns browser status immediately) {server:github}
2026-11-17T08:03:59.863+02:00 OAuth not applicable based on config {server:github}
2026-11-17T08:03:59.863+02:00 httpapi/server.go:883 Failed to trigger OAuth login (same error)
2026-11-17T08:03:59.863+02:00 POST /api/v1/servers/github/login status=500 duration=0.000744209

Live diagnostics collected on November 17

mcpproxy doctor --server github --output json:

{
  "attention": {
    "kind": "sign_in_required",
    "summary": "github: sign in required",
    "detail": "OAuth · api.githubcopilot.com",
    "fix": {"verb": "login", "label": "Sign in", "target": "/servers/github"},
    "since": "2026-11-14T08:17:50.349499+02:00"
  },
  "diagnostics": {
    "missing_secrets": [],
    "oauth_issues": [],
    "oauth_required": [{"server_name": "github", "state": "unauthenticated", "message": "Run: mcpproxy auth login --server=github"}],
    "runtime_warnings": [],
    "upstream_errors": [],
    "total_issues": 1
  }
}

mcpproxy auth status --server github also reports Sign-in required and recommends mcpproxy auth login --server=github. The CLI login command itself was not run; the two captured failures are from the tray/API.

Proxy management status: connected=false, connecting=false, state="Pending Auth", retry_count=20, should_retry=false, last retry 2026-11-14T08:17:50.060023+02:00.

Impact is functional: an attempted GitHub MCP get_file_contents call is refused with Server 'github' is not connected (state: Pending Auth).

Source-level cause

  1. httpAuthStrategies() / runAuthStrategies() use headers -> no-auth -> OAuth when no explicit OAuth block exists. Thus a server with headers can reach OAuth and be parked awaiting sign-in.
  2. ShouldUseOAuth() returns false when OAuth == nil && len(Headers) > 0 (lines 2201–2206). Its comment says headers are tried first with OAuth as fallback, but the boolean is also used as an absolute manual-login veto.
  3. StartManualOAuthQuick() applies that config-only preflight and returns the exact logged error at lines 2913–2915 before creating the transient OAuth client.
  4. Client.StartOAuthFlowQuick() repeats the same ShouldUseOAuth guard, so changing only the manager guard would not fully address this path.

The current configuration plus the matching logged error make this a well-supported cause of the HTTP 500. The separate reason why GitHub stopped accepting the prior Bearer credential remains unknown: these logs do not establish expiration, revocation, scope failure, or credential-resolution failure. missing_secrets=[] does not prove the credential is valid. No credential was printed or sent to an additional endpoint to test it.

Suggested regression coverage

  • Static-header server with no OAuth block receives a genuine auth challenge and valid OAuth metadata: its resulting Pending Auth action must be usable or offer correct static-credential repair.
  • Keep header-first authentication working for a valid Bearer credential.
  • Keep network failures distinct from authentication challenges.
  • Verify both manager and core quick-login guards and tray/API/diagnostic action consistency.
  • If GitHub requires a configured client ID or registration, surface that actionable requirement after eligibility is resolved; do not imply the missing-client-ID issue was reproduced here.

Checks / collection scope

  • Searched existing issues for the exact rejection, OAuth not applicable, and GitHub/OAuth titles. Found no matching duplicate; #975 concerns an empty client_id after browser launch, a different failure stage.
  • Ran and reviewed server-scoped doctor and auth status.
  • Reviewed retained main and HTTP logs (including compressed rotations) and the GitHub server log. Extracted 4,264 GitHub main-log records, 3 matching HTTP route records, and 26,322 GitHub server-log records; the server log covers August 14–November 14. Counts reflect collection time and retained files, not every historical event.
  • Published excerpts are limited to this server and contain no Bearer values, secret names, API keys, OAuth tokens, or authorization query secrets.
  • No server configuration, credentials, connection state, or source code was changed during this investigation. No extra login attempt was triggered.

algis-dumbris avatar Nov 17 '26 06:11 algis-dumbris