Skip to content

rmcp OAuth tokens never refresh based on expires_at #6572

Closed

Description

@LaelLuo

Summary

When Codex uses the rmcp streamable HTTP transport against OAuth-enabled MCP servers (e.g. Notion), the cached OAuthTokenResponse keeps the original expires_in duration forever. AuthorizationManager::get_access_token() only refreshes when that duration reaches zero, so tokens that are still considered valid locally never trigger a refresh even after the server rotates them. Eventually every request—including the initialization handshake—fails with Auth required, forcing the user to run codex mcp login ... again.

Expected

The client should derive the remaining lifetime from the stored expires_at (or an equivalent timestamp) and refresh via the refresh_token before the server-side expiry, so long-lived SSE connections continue seamlessly.

Actual

Because expires_in stays at the original value, rmcp never refreshes; once the server-side token rotation happens, all subsequent requests fail immediately with Auth required.

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    mcpIssues related to the use of model context protocol (MCP) servers
    authIssues related to authentication and accounts
    on Nov 13, 2025
  2. github-actions commented on Nov 13, 2025

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. gpeal commented on Nov 13, 2025

    @gpeal
    Contributor

    What version of the CLI are you on? 0.56 had an oauth token refresh fix from #6234

  4. LaelLuo commented on Nov 13, 2025

    @LaelLuo
    ContributorAuthor

    In fact, I have been using a version that I maintain based on the main branch. This bug occurs when the mcp accessToken expires and codex is launched; it prompts for a re-login instead of automatically refreshing the accessToken. Moreover, if the accessToken expires during the operation of codex, the accessToken is also not automatically refreshed. I checked the automatic refresh logic of rmcp, and it only triggers when expires_in is 0. However, expires_in is not updated in reality, so the logic for automatically refreshing the accessToken will never be triggered.

  5. added a commit that references this issue on Nov 18, 2025
    f3d4e21
  6. added a commit that references this issue on Dec 2, 2025
    b84ae6c
  7. added a commit that references this issue on Jun 27, 2026
    9d0b7dc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIauthIssues related to authentication and accountsbugSomething isn't workingmcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions