Codex MCP OAuth sessions expire and require application restart
What version of the Codex App are you using (From “About Codex” dialog)?
26.707.51957
What subscription do you have?
Pro
What platform is your computer?
MaDarwin 25.5.0 arm64 arm
What issue are you seeing?
I use the Notion MCP server extensively for work. Recently, its OAuth/MCP session appears to expire or become invalid after approximately one hour, whereas it previously remained usable significantly longer.
The first failure observed was:
Transport send error: ... StreamableHttpClientWorker ... Auth required
After running:
codex mcp login notion
OAuth completed successfully:
Successfully logged in to MCP server 'notion'.
However, the running Codex desktop session still could not use the connector. The MCP tools disappeared from the available tool registry, and attempts to call them produced behavior equivalent to:
tools.mcp__notion__notion_fetch is not a function
The CLI reported the server as healthy:
notionenabled: truetransport: streamable_httpAuth: OAuth
Only quitting and relaunching Codex caused the MCP tools to reappear and work again.
What steps can reproduce the bug?
- Configure and authenticate the Notion MCP server in Codex.
- Use the Notion MCP normally for page fetches, searches, and updates.
- Continue using Codex for approximately an hour or more.
- Attempt another Notion MCP operation.
- The operation fails with
Auth required, or the MCP tools disappear from the active tool registry. - Run
codex mcp login notion; OAuth succeeds. - The CLI reports the MCP server as enabled and authenticated, but the already-running Codex desktop session still cannot call the tools.
- Quit and relaunch Codex.
- After relaunch, the MCP tools are sometimes restored immediately. In other cases, OAuth login must be repeated, followed by another Codex restart.
The issue is intermittent and may depend on MCP session lifetime or transport state. I do not have a deterministic code snippet because this involves Codex desktop MCP session lifecycle rather than application code.
Diagnostics observed:
codex mcp get notion
reported:
enabled: truetransport: streamable_httpAuth: OAuth
Session ID, token usage, and context-window usage were not available in the error output.
What is the expected behavior?
When the MCP OAuth access token or streamable HTTP session expires, Codex should refresh or reauthenticate the connector automatically and update the active MCP tool registry.
The user should not need to quit and relaunch the entire Codex application, repeat OAuth login multiple times, or restart Codex after successful authentication.
After codex mcp login notion succeeds, the running Codex desktop session should be able to use the refreshed MCP connection immediately.
Additional information
This appears to involve two related failures:
- The MCP transport reports
Auth required, suggesting the OAuth/session credential is no longer accepted. - After successful CLI reauthentication, the running Codex desktop session retains stale MCP state and does not rehydrate the connector tools until a full application restart.
The Notion page operations themselves are valid. Before the failure, the same connector successfully fetched and updated Notion pages. After restarting Codex, the same operations succeeded again.
Potential areas to investigate:
- OAuth refresh-token/session lifetime for streamable HTTP MCP servers;
- Codex desktop MCP transport reconnection;
- synchronization between CLI MCP authentication state and desktop tool registration;
- automatic tool-registry refresh after MCP authentication or transport recovery.
Environment:
- Codex desktop
- macOS
- MCP server:
notion - Transport:
streamable_http - Authentication: OAuth
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Analysis (community)
Thanks for tracking this — attempting a residual-focused analysis aligned with docs/contributing.md (invitation-only: analysis in-thread, no unsolicited PR).
mcp-auth)Observed (from issue + public residual signal)
What version of the Codex App are you using (From “About Codex” dialog)? 26.707.51957 ### What subscription do you have? Pro ### What platform is your computer? MaDarwin 25.5.0 arm64 arm ### What issue are you seeing? I use the Notion MCP server extensively for work. Recently, its OAuth/MCP session appears to expire or become invalid after approximately one hour, whereas it previously remained usable significantly longer. The first failure observed was: `Transport send error: ... StreamableH
Root-cause hypothesis
OAuth refresh / mid-session tool drop / forced re-login appears as a lifecycle bug across app-server and CLI: token refresh soft-fails, MCP init hangs, tools vanish without clear recovery.
High-level fix outline (not a PR)
Related
#32590, #17265 family — join existing analysis, do not refile umbrella.
Questions for maintainers
Happy to refine with more measurements or code pointers. No unsolicited PR from me.
Analysis (community)
Residual analysis for #32590 (MCP OAuth sessions expire; restart required) — invitation-only. Distinct from broader OAuth callback/
issthreads: focus is in-session refresh/reconnect after expiry. No unsolicited PR.Deterministic evidence (code + local TRACE)
Code (
5dd992acd3):codex-rs/rmcp-client/src/oauth.rs:StoredOAuthTokenStatus::Usable | AuthorizationRequired | Missing(≈L104–L126)token_needs_refresh/.refresh_token()path (≈L164–L166)oauth.rsmodulesrefresh_lock,refresh_transactioncodex-rs/rmcp-client/src/auth_status.rs:McpAuthState::OAuthsupports_oauth_login/ streamable HTTP OAuth discovery)auth_status.rs≈L197 message pattern for MCP server name/url).Runtime (
codex-cli 0.146.0-alpha.6):codex_mcp::connection_manager= 1745 rows — MCP lifecycle is actively chatty under real sessions, consistent with reconnect/init churn when auth state flips.Root-cause hypothesis
When refresh soft-fails or returns AuthorizationRequired mid-session, tool surfaces disappear until full process restart re-runs discovery + token load. Missing: user-visible refresh failure event + singleflight-safe in-session reconnect that does not block the entire tool registry indefinitely.
High-level fix outline (not a PR)
OAuthCredentialsStoreMode) and when keyring vs file loses tokens across upgrades.Questions for maintainers
No unsolicited PR from me.
Additional data from Codex CLI 0.147.0 on macOS arm64 against a Streamable HTTP OAuth MCP server.
I used the app-server protocol as a deterministic probe: initialize, start an ephemeral thread, call mcpServerStatus/list with that thread ID, then invoke one read-only MCP tool directly through mcpServer/tool/call.
With a 5-second access-token TTL, three fresh processes each contacted the provider, completed the refresh transaction, loaded the tool catalog, and completed the direct tool call (3/3). After restoring the normal 1-hour TTL, the first process refreshed and succeeded; a second process reused the persisted credential and also succeeded (2/2).
I therefore cannot reproduce post-refresh catalog loss after a clean reauthorization on 0.147.0. An earlier stale state did show OAuth in codex mcp list while the server exposed zero tools; repeating the MCP login repaired it. This suggests codex mcp list confirms that a credential is stored, but is not itself proof that the current process loaded a usable catalog.
One possible regression-coverage improvement: the current streamable_http_oauth_startup test exercises refresh through initialize, but does not appear to assert a subsequent tools/list result or propagation into the client tool catalog. Extending it through tools/list could guard the symptom reported here.
No credentials, endpoint names, or workspace identifiers are included in this report.
Correction and follow-up to my previous comment: that result used mcpServerStatus/list plus direct tool dispatch, which can succeed through a temporary connection even when the active thread did not expose the MCP tool to the model. Please treat the earlier non-reproduction conclusion as superseded.
I revised the probe to start a fresh ephemeral thread and run a real model turn before any status or direct-call diagnostics. The process used a read-only OAuth grant and an effective MCP tool allowlist containing only one read-only tool; apps, web search, collaboration, and image tools were disabled. The oracle requires a turn-scoped, item-ID-correlated model MCP call with the exact requested argument.
On Codex CLI 0.147.0 with a 5-second access-token TTL, three fresh processes produced the same result:
This reproduces the catalog-loss symptom after successful refresh while showing that transport, authorization, tools/list through the temporary status connection, and literal direct dispatch are healthy. The failure is specifically active-thread model catalog hydration.
No credentials, endpoint names, workspace identifiers, or raw tool results are included. The suggested regression test should therefore assert that the refreshed server tool reaches the active thread model tool registry, not only that initialize or an independent tools/list call succeeds.
Related report from current ChatGPT/Codex Desktop on macOS (Desktop 26.803.41515, bundled codex-cli 0.147.0-alpha.6.5).\n\nThis appears to be the same connector/tool-exposure lifecycle class, but affects built-in app connectors:\n\n- HubSpot and Google Drive both complete OAuth, then the desktop UI reverts to “Connect”.\n- Fresh connector links appear in the local app-tools cache, but neither connector’s tools become available in the desktop session.\n- Both connectors work in ChatGPT web on the same account.\n- Moving aside ~/.codex/cache/codex_apps_tools and ~/.codex/cache/codex_app_directory and restarting did not help.\n- Other connectors, including Airtable, work in the same desktop session.\n\nSo the connection/auth handshake appears to complete, but the desktop active-thread tool registry is not hydrated. This seems closely related to the active-thread catalog-loss behavior described here, and to Google Drive’s separate exposure issue in #25854.\n\nCould maintainers confirm whether built-in Codex Apps connectors are covered by this issue, or whether this should be tracked separately?
Additional deterministic reproduction on current ChatGPT/Codex Desktop against a private remote Streamable HTTP OAuth MCP server.
No endpoint, organization, workspace, tenant, user, client, credential, token/family identifier, raw log, transcript, tool payload, or screenshot is included here.
Environment
26.810.52044(build6662)0.148.0-alpha.90.145.027.0(26A5388g)Reproduction
tools.mcp__<redacted>__<redacted_tool> is not a functionKey distinction
This is not a provider-side refresh rejection, refresh-token expiry, family revocation, or catalog outage. Provider-side refresh succeeds repeatedly while the desktop process transitions to
Authentication expiredand drops the model-visible tool namespace.This corroborates the active-thread catalog-hydration diagnosis in the previous comments: transport/auth state can be healthy while refreshed MCP tools never reach—or no longer remain in—the active thread model registry.
Expected behavior
After a successful OAuth refresh, Codex should persist/adopt the refreshed credential and keep or rehydrate the MCP tools in the active thread. On process restart it should reload the valid refreshed credential and catalog without requiring another manual Reconnect.