Skip to content

MCP OAuth refresh regression after upgrade to rmcp 1.7.0 #25903

Closed

Description

@Savlar

What version of Codex CLI is running?

0.136.0

What subscription do you have?

Plus

Which model were you using?

gpt-5.5

What platform is your computer?

Windows 11

What issue are you seeing?

After logging in to an OAuth streamable HTTP MCP server with:

codex mcp login

Codex logs in and stores OAuth credentials successfully. The identity provider is Keycloak, and the login creates a Keycloak regular SSO session and also stores a refresh token with offline_access.

In Codex CLI 0.136.0, once the regular SSO OAuth access token expires, running:

/mcp

causes Codex to show no available tools for that MCP server. The FastMCP server shows HTTP 401.

This used to work in 0.135.0.

What steps can reproduce the bug?

  1. Configure a streamable HTTP MCP server using OAuth.

  2. Use Keycloak as the OAuth provider.

  3. Ensure the OAuth login grants offline_access and returns a refresh token.

  4. Run:

    codex mcp login

  5. Start Codex CLI 0.136.0.

  6. Confirm /mcp initially lists the MCP tools.

  7. Wait until the access token expires, without letting the refresh token expire.

  8. Run /mcp again.

  9. Observe that Codex lists no tools for the MCP server.

  10. Check the MCP server logs.

What is the expected behavior?

If Codex has a valid OAuth refresh token for an MCP server, it should refresh the expired token before MCP initialization or tool listing, then continue using tools without requiring new login.

Additional information

This appears to be a regression related to rmcp bump between 0.135.0 and 0.136.0.

  • 0.135.0 used rmcp 0.15.0.
  • 0.136.0 uses rmcp 1.7.0.

The likely cause is how RMCP handles OAuth token expiry.

  • In rmcp 0.15.0, AuthorizationManager::get_access_token() refreshed if refresh_token().is_some() and the token was expired.
  • In rmcp 1.7.0, refresh depends on both expires_in and RMCP token_received_at.

Activity

  1. added
    bug
    on Jun 2, 2026
  2. added
    CLI
    mcp
    auth
    on Jun 2, 2026
  3. Savlar commented on Jun 5, 2026

    @Savlar
    Author

    I'm closing this since it appears to be fixed by #26482, specifically the squash commit 4de7a2b9d8 (fix(rmcp): refresh expired OAuth tokens before startup).

    The root cause seems to be the rmcp 1.7.0 behavior change where missing expiry is treated as unknown, so Codex-loaded expired OAuth credentials could be used as-is during MCP
    startup. #26482 changes Codex to mark known-expired persisted MCP OAuth tokens with expires_in = 0, which causes RMCP to refresh before the first initialize request.

    That matches this issue’s symptom: after the access token expires, /mcp creates/initializes an MCP client, sends the stale bearer, gets 401, and shows no tools.

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

    CLIauthbugmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions