Skip to content

GitHub MCP OAuth DCR opens authorization URL with empty client_id #975

Closed

Description

@nagydavid

Problem

GitHub MCP OAuth login opens GitHub authorization with an empty client_id, producing a 404.

https://github.com/login/oauth/authorize?client_id=&code_challenge=...&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A53015%2Foauth%2Fcallback&resource=https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F&response_type=code&scope=repo+read%3Aorg+read%3Auser+user%3Aemail+read%3Apackages+write%3Apackages+read%3Aproject+project+gist+notifications+workflow+codespace&state=...

Expected

For OAuth configuration without a configured client ID, discover OAuth metadata and complete Dynamic Client Registration (RFC 7591) before opening authorization, then send registered client_id.

Actual

Authorization opens directly with client_id= empty. GitHub returns 404.

Reproduction

  1. Configure https://api.githubcopilot.com/mcp/ upstream with OAuth and no client_id.
  2. Run mcpproxy auth login --server=github.
  3. Browser opens URL above and returns 404.

Context

#83 / #116 made oauth.client_id optional for DCR. Current flow appears to skip or fail DCR without surfacing discovery/registration failure.

Observed version: v0.55.0.

Activity

  1. Dumbris commented on Aug 13, 2026

    @Dumbris
    Member

    Thanks for the clean report — root-caused and reproduced, fix is up in #976.

    Root cause: GitHub's authorization server (https://github.com/login/oauth) doesn't advertise a registration_endpoint in its RFC 8414 metadata, so Dynamic Client Registration is impossible there. mcpproxy attempted DCR, got "server does not support dynamic client registration", logged a warning, and then intentionally fell back to "public client OAuth with PKCE, no client_id". That fallback premise is wrong — OAuth public clients still require a client_id (PKCE replaces the client secret, not the id) — so the authorize URL was built with client_id= empty and GitHub 404s it. Worse, both the REST login endpoint and mcpproxy auth login reported success on that broken URL.

    Fix (#976): when no client_id is available after the DCR attempt, mcpproxy now aborts with a structured oauth_client_id_required error (CLI exits 1 with the full error block and suggestion) instead of ever opening a guaranteed-broken authorization URL.

    Workaround today: register your own GitHub OAuth App (callback URL http://127.0.0.1:*/oauth/callback — any port, mcpproxy allocates dynamically; if your provider requires a fixed port, check the login log line for the actual callback port) and set it on the server entry:

    {
      "name": "github",
      "url": "https://api.githubcopilot.com/mcp/",
      "protocol": "http",
      "enabled": true,
      "oauth": { "client_id": "<your OAuth app client id>" }
    }

    Verified locally that a configured oauth.client_id produces a working authorize URL carrying it.

  2. nagydavid commented on Aug 26, 2026

    @nagydavid
    Author

    Follow-up: #975 correctly prevents the broken empty client_id authorization URL, but the GitHub static-client OAuth path is still not workable end-to-end.

    Environment

    • mcpproxy v0.61.0 (macOS arm64, daemon mode)
    • Upstream: https://api.githubcopilot.com/mcp/
    • Static oauth.client_id configured from a GitHub OAuth App

    Problem 1: callback port is dynamic for static credentials

    GitHub OAuth Apps require one exact callback URL and reject http://127.0.0.1:*/oauth/callback as invalid. mcpproxy allocates a free callback port for each login; in this session it changed from 53015 to 54025.

    The current implementation persists a callback port only for DCR-created credentials, not a configured static oauth.client_id. This makes reauthorization unreliable because the GitHub OAuth App callback URL must be manually changed to match the latest mcpproxy port before each login.

    Expected: support configured or persisted callback-port/redirect-URI reuse for static OAuth credentials, with a documented configuration path.

    Problem 2: successful GitHub browser authorization does not connect mcpproxy

    I configured the GitHub OAuth App callback URL to exactly match the active mcpproxy listener:

    http://127.0.0.1:54025/oauth/callback
    

    Then ran:

    mcpproxy auth login --server=github

    GitHub browser flow reported Authentication was successful. However mcpproxy remained Sign-in required; github stayed in Error with OAuth authentication required, no token appeared to persist, and zero GitHub MCP tools were discovered.

    Expected: after browser success, mcpproxy must receive the callback, exchange/store the token, and connect to the official GitHub MCP upstream.

    Impact

    The official GitHub MCP endpoint is OAuth-only. PAT cannot be used as a fallback for this endpoint, so GitHub OAuth Apps with static client IDs need this flow to work reliably.

  3. Dumbris commented on Aug 27, 2026

    @Dumbris
    Member

    Thanks — both of these reproduce, and both turned out to be real bugs. Filed and fixed separately.

    First, a correction to my own earlier comment here. I suggested registering http://127.0.0.1:*/oauth/callback as the OAuth App callback URL, "any port". Retracting that: it isn't valid GitHub syntax, and it can't work in principle. GitHub does have wildcard matching on callback URLs now, but their docs are explicit that it covers subdomains and subdirectory paths only — "the redirect URL's host (excluding subdomains) and port must exactly match the callback URL". A loopback port that moves between logins can never satisfy that. You were right to push back.

    Problem 1 — confirmed, filed as #1066, fixed in #1069

    Your port move (53015 → 54025) is exactly what #1066 records: two consecutive logins on the same daemon allocated http://127.0.0.1:54108/oauth/callback, then http://127.0.0.1:54308/oauth/callback. Reproduced against a GitHub-shaped fake provider — RFC 8414 metadata advertising S256 and deliberately no registration_endpoint, like github.com/login/oauth. Three distinct causes:

    1. Only the DCR-succeeded branches ever persisted the callback port, so a static oauth.client_id login stored callback_port: 0.
    2. Port 0 plus a non-empty client_id then hit the "legacy DCR credentials, clearing for re-registration" branch and wiped your stored credentials on the next login. A client_id that came from mcp_config.json can never be re-registered, so that branch was always wrong for static clients.
    3. oauth.redirect_uri existed in the config schema, was diffed on reload and was documented — but the OAuth flow never read it. The redirect URI was unconditionally the freshly allocated one. That's why my wildcard workaround had no correct alternative at the time.

    The supported path now is an explicit pin:

    {
      "name": "github",
      "url": "https://api.githubcopilot.com/mcp/",
      "protocol": "http",
      "enabled": true,
      "oauth": {
        "client_id": "<your OAuth App client id>",
        "redirect_uri": "http://127.0.0.1:54108/oauth/callback"
      }
    }

    Register that exact string as the OAuth App's Authorization callback URL — same host, same port, same path. mcpproxy binds that port and sends the configured URI to the provider verbatim. It must be an RFC 8252 loopback redirect: http scheme, loopback host, explicit port, /oauth/callback path. Pick a port nothing else on your machine claims; a malformed value or an occupied port fails the login with an error that names redirect_uri. Without redirect_uri, mcpproxy now persists the port of the first successful login and reuses it.

    Docs: Configuration → Pinning the callback port with redirect_uri (on main; docs.mcpproxy.app picks it up on the next site build).

    Problem 2 — two candidates, and one log line tells them apart

    There are two known ways to get exactly what you saw — browser says success, mcpproxy stays signed out, 0 tools — and I can't tell from here which one hit you.

    Candidate A — #1067, fixed in #1068. Each upstream had a single shared 1-buffer callback channel with no per-flow routing. A background reconnect could park its own waiter on it, win the race against your manual login, and reject the real authorization code as a state mismatch — so no /token request was ever made. The callback page rendered "Authorization Successful" unconditionally, including on that drop path. #1068 dispatches callbacks by state, gives each flow its own single-use channel, returns an explicit HTTP 400 "Authorization Failed" page for an unknown or expired state, and stamps the failure onto the server's status so it shows up in mcpproxy upstream list instead of only in the log.

    Candidate B — a missing client_secret. A GitHub OAuth App is issued a client secret at creation, and GitHub's token endpoint appears to expect it: exchanging with client_id + PKCE alone returned incorrect_client_credentials in a probe. Treat that as a lead, not a finding — it's a single observation, and GitHub does advertise code_challenge_methods_supported: ["S256"] at /.well-known/oauth-authorization-server/login/oauth (that metadata describes the GitHub Apps user-authorization flow, not classic OAuth Apps). If you hit incorrect_client_credentials, add "client_secret" next to "client_id" — and please say so, because we'd rather confirm this than infer it.

    The discriminator. On macOS the core log is ~/Library/Logs/mcpproxy/main.log (not under ~/.mcpproxy/, unless you run a custom --data-dir, in which case it's <data-dir>/logs/main.log). Retry the login, then:

    grep -iE "state mismatch|incorrect_client_credentials|failed to exchange authorization code" ~/Library/Logs/mcpproxy/main.log

    One more thing that would help: did the browser step take more than about two minutes? The background waiter that mcpproxy auth login parks had a hardcoded 120s cap even though the manager hands it a 30-minute context — a GitHub sign-in with 2FA or an org-approval step blows through that while you're still in the browser. #1068 makes that waiter follow the caller's deadline. (The synchronous in-connect OAuth paths still use their own 120s wait; that's tracked separately.)

    Status

    #1068 and #1069 are both merged to main. Neither is in v0.61.0, which was cut the day before them, and nothing has been tagged since — so they land in the next release. A follow-up, #1070, fixes several things QA found in the redirect_uri pin itself: an [::1] pin bound IPv4 and so silently timed out, and the "fail loudly" errors above were going to a no-op logger and reaching no log at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions