Keep concurrent MCP OAuth writes from wiping tokens - #487
Closed
TheGreatAxios wants to merge 1 commit into
Closed
Conversation
Auth-store last-writer-wins full snapshots let a second session codeVerifier save erase tokens just written by the first. Serialize read-modify-write per server, use unique temp files, and drop stale DCR clients when the loopback redirect port no longer matches.
TheGreatAxios
force-pushed
the
fix/mcp-oauth-token-persist
branch
from
August 21, 2026 15:12
70892fe to
27d3136
Compare
4 tasks
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MCP OAuth auth state was full-snapshot last-writer-wins. A concurrent session (or second connect) could save a new PKCE code verifier and erase tokens just written by another session — Linear often ended with only client registration + verifier and no tokens, while the UI could still look connected. Concurrent re-auth also races PKCE (
Invalid PKCE code_verifier). Stale dynamic client registration against a previous loopback port made re-auth fail as well.This has been latent since remote MCP OAuth landed (#44).
Changes
updateAuthStateso field patches merge instead of clobberingTest plan
bun run typecheckbun test ./src/mcptokenson diskLinear
Fixes CL-6679
https://linear.app/abklabs/issue/CL-6679/keep-concurrent-mcp-oauth-writes-from-wiping-tokens