MCP OAuth stuck at "unauthenticated" — no browser launch, state mismatch, cross-platform

Status Open
Maintainer reply None cached
Activity 0 comments · opened Jul 17, 2026

Environment: Windows (reported), but root cause looks platform-agnostic — see below.

Symptoms:

  1. Adding an MCP server that requires OAuth does not launch a browser automatically.
  2. Manually opening the printed auth URL and completing login does not get captured back by the CLI.
  3. Pasting the redirect URL back into the CLI does nothing.
  4. /mcp permanently reports the server as "✗ not authenticated", with:

OAuth state mismatch - possible CSRF attack

Suspected causes (not yet confirmed, need CLI-side investigation):

  • Automatic browser-launch step may not fire, or may use a launch mechanism that isn't reliable across OS/environment (e.g. missing xdg-open on some Linux setups, blocked start/cmd on locked-down Windows machines, headless/SSH/container sessions with no browser at all).
  • The CLI's local loopback callback server may fail to bind (firewall/AV interference, corporate proxy, WSL↔Windows-host port mismatch), which would explain why pasting the redirect link back "does nothing" — there's no listener to receive it.
  • The "OAuth state mismatch" suggests the state value the CLI generates at authorize-time isn't matching what comes back on the callback. We checked our own MCP server implementation (cfos) and confirmed it passes the client-issued state back through the redirect chain unmodified (byte-for-byte, no re-encoding) — so if state mismatch is happening, it looks like it's occurring inside the CLI's own compare/loopback logic, not something a server can cause.

Ask: could the CLI provide better diagnostics here — e.g. explicitly say whether the browser-launch step ran, whether the loopback listener bound successfully and on which port, and log the expected vs. received state value (or at least whether they differ) so users/server operators can tell which of the three steps failed?

Impact: users are completely blocked from authenticating to any OAuth-gated MCP server, with no actionable next step other than manually pasting a link that has no effect.

View original on GitHub ↗