diff --git a/codex-rs/rmcp-client/src/rmcp_client.rs b/codex-rs/rmcp-client/src/rmcp_client.rs index 90b09d724c..d16a4a9e55 100644 --- a/codex-rs/rmcp-client/src/rmcp_client.rs +++ b/codex-rs/rmcp-client/src/rmcp_client.rs @@ -770,6 +770,12 @@ impl RmcpClient { matches!(auth_err, AuthError::NoAuthorizationSupport) }) => { + if initial_tokens.token_response.0.expires_in() == Some(Duration::ZERO) + { + return Err(anyhow!( + "stored OAuth access token for MCP server `{server_name}` is expired and OAuth metadata discovery is unavailable" + )); + } let access_token = initial_tokens .token_response .0