Keep concurrent MCP OAuth writes from wiping tokens - #499
Merged
TheGreatAxios merged 2 commits intoAug 22, 2026
Merged
Conversation
4 tasks
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
cl-6679-keep-concurrent-mcp-oauth-writes-from-wiping-tokens
branch
from
August 22, 2026 17:50
27d3136 to
bb180e5
Compare
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
Supersedes closed PR #487 (same commit 27d3136). Branch was renamed
fix/mcp-oauth-token-persist→cl-6679-keep-concurrent-mcp-oauth-writes-from-wiping-tokens, which closed #487 as a side effect.