Files
codex/codex-rs/rmcp-client
Andrei Eternal 5ac0b8768d Surface MCP reconnect signals when expired OAuth tokens cannot refresh (#43947)
## Why

Refresh failures could leave expired MCP OAuth credentials reporting ordinary errors instead of signaling that authentication is required, preventing tool calls from offering a reconnect signal.

## What changed

- Classify provider failures and timeouts as `AuthorizationRequired` when the access token has expired. Keep proactive refresh failures as ordinary errors while the token remains valid.
- Reread stored credentials after a failed refresh and adopt a valid login completed during the request, enforcing the existing issuer binding for refresh tokens. Preserve stored credentials for later retries.
- Convert authentication-required tool-call errors into a reconnect message with `mcp/www_authenticate` metadata, without exposing provider or transport details.

## Testing

Add coverage for startup and runtime OAuth recovery, proactive refresh failures, concurrent login adoption, issuer mismatches, credential preservation, and successful retries. Verify failed local refreshes do not send tool calls and server-rejected calls are not replayed.

GitOrigin-RevId: 9cf64b0452685d2085df5dc0bcecee16ffe42e47
2026-09-09 00:03:41 +00:00
..