Contents
PR Summary
What problems was I solving
The internal MCP CLI stores OAuth tokens, client info, and PKCE state in a shared JSON cache file that multiple agent skills and agent processes can access concurrently. Without serialization, concurrent read-modify-write cycles could clobber the cache. In addition, gateway-side session eviction produced transient Unknown MCP session errors that caused mcp oauth call to fail with no recourse from the CLI.
What user-facing changes did I ship
No customer-facing UI or API changes. Internal agent skills that invoke the MCP CLI (e.g., dash0-mcp, firetiger-mcp) should experience fewer auth failures from concurrent cache access or transient MCP session loss during mcp oauth call.
How I implemented it
Serialized OAuth cache mutations via an advisory lock file created atomically next to the cache. The PKCE code verifier is now held process-local during the active flow, while still being written to the cache for compatibility. Refactored mcp oauth call to read arguments once and retry once with a fresh Client/Transport (and therefore a fresh gateway session) only when the error message indicates "Unknown MCP session".
Description for the changelog
Added per-file locking to the MCP CLI OAuth cache provider to prevent concurrent read-modify-write races. The PKCE code verifier is now kept process-local during an active OAuth flow while remaining compatible with the existing cache format. mcp oauth call now retries once after an "Unknown MCP session" transport error by creating a fresh session.