Repository navigation
Description
What happened
Adding a remote OAuth upstream (Linear, https://mcp.linear.app/mcp, Streamable HTTP, dynamic client registration, oauth.redirect_uri pinned to a loopback port) and approving it in the browser failed twice with the consent step succeeding. The callback reached mcpproxy both times ("Authorization Successful" page, OAuth callback parameters delivered to the waiting flow), and then the code exchange failed:
ERROR core/connection_oauth.go ❌ Failed to exchange authorization code
error: failed to send token request: Post "https://mcp.linear.app/token": ... instance retired (removed, replaced or quarantined)
The third attempt worked (token stored with a refresh token, 76 tools discovered, a call_tool_read of list_teams returned data), so the flow itself is fine. Both failures were the in-flight OAuth flow being torn down by something else.
Build: main at 14cb288 (v0.1.0 personal), Linux amd64, fresh data dir, require_mcp_auth: true, enable_socket: false.
Cause 1: the quarantine inspection exemption expired during the login
A new upstream starts quarantined. About 10 minutes after the login started the log shows Inspection exemption expired, triggering disconnect and then Skipping quarantined client every minute. The login was started with POST /api/v1/servers/linear/login, and I approved in the browser about 18 minutes later. The exchange then failed as above. Nothing told the person approving that the login had been invalidated.
Cause 2: the informational scan restarts a pending-auth server and retires the flow
After POST /api/v1/servers/linear/unquarantine and a fresh login, I approved within about a minute and it failed again. The log shows why:
WARN scanner/service.go Timed out waiting for server to connect for scan {"server":"linear","timeout":"30s"}
WARN scanner/service.go Could not export live tool definitions for scanning {"error":"server linear is not connected"}
INFO server/scan_informational.go Tool export returned 0, retrying after EnsureConnected
INFO server/server.go Replacing the server's client to recreate it with fresh secret resolution
INFO runtime/lifecycle.go Replaced upstream server instance {"generation":8,"old_instance":5,"new_instance":6}
A server in Pending Auth can never be "connected", so the scan waits 30 s, then replaces the client. Replacing the client retires the instance that owns the pending OAuth state (PKCE verifier and callback waiter), so the code that arrives afterwards cannot be exchanged. The scan had been started by the unquarantine, and the replacement landed after I had already requested a new login URL.
Expected
- A scan (or any background restart) should skip a server whose state is
Pending Author has an OAuth flow in progress, or it should keep the in-flight flow alive across the replacement. - If a login is invalidated, the callback page should say so instead of "Authorization Successful", and
GET /api/v1/serversshould show a reason. - The inspection exemption should not expire while an OAuth flow for that server is waiting.
Workaround
Unquarantine, wait until the scan has finished (it times out once), request the login URL again, and approve within a couple of minutes.
Side note
The stored token is readable as plaintext in config.db (already tracked in #1697).
Activity
fix(runtime): require an access token for OAuth status (#1725)
Dumbris commentedon Oct 22, 2026
Thanks for the precise diagnosis, both causes were exactly as you described. Fix in #1739:
Pending Auth, and if so scans without calling the reconnect that replaced the instance (and logsServer is waiting on an OAuth login; scanning without reconnecting it). No more 30 s wait followed by "Replacing the server's client".GET /api/v1/serversdoes not carry a per-server reason for this case: the retired instance's failure is deliberately not recorded on the server status (a same-name replacement would inherit it), so the page and the log are the surfaces. Nothing in the change approves or unquarantines anything.fix(oauth): keep a pending login alive across scans and the quarantin…
james-crowley commentedon Oct 23, 2026
Confirmed fixed on main (a983081, #1739). I used the repo's fake OAuth server (
tests/oauthserver), with the proxy on 127.0.0.1, and compared main against the parent commit (2146860):The new tests pass with
-raceon main. The scanner test fails on the parent (it reconnects the server awaiting login). Thanks for the quick fix.