What issue are you seeing?
Summary
Codex persists a refresh_token for a routed MCP server in ~/.codex/.credentials.json, but it does not automatically refresh the access token when the token expires.
As a result, once the access token expires:
- MCP tool calls start failing with auth errors
- automations and later runs break
- the only recovery is manual CLI login and browser reauth
This defeats the purpose of storing a refresh token.
Environment
- Product: Codex desktop / Codex MCP client. MacOS 26.3.1 (a)
- Date observed: April 9, 2026
Expected behavior
If Codex has a valid stored refresh_token for the MCP server, it should automatically refresh the expired access token and continue making authenticated MCP calls without requiring manual CLI login.
This is especially important for:
- automations
- recurring background runs
- later thread/tool invocations after some idle time
Actual behavior
When the access token expires, Codex starts returning auth failures instead of using the stored refresh token to recover automatically.
Observed failure:
{"success": false, "error": "invalid_grant", "msg": "Authorization required"}
### What steps can reproduce the bug?
- Auth to MCP, observe the credentials and refresh token stored in credentials.json
- Wait for the token expiry, access the MCP again (prior to refresh token expiry), it will fail on auth and not automatically refresh as it should
- Use the CLI to authenticate manually, it will then work again
### What is the expected behavior?
Within the refresh token expiry window re-auth should be automatic
### Additional information
_No response_
What issue are you seeing?
Summary
Codex persists a
refresh_tokenfor a routed MCP server in~/.codex/.credentials.json, but it does not automatically refresh the access token when the token expires.As a result, once the access token expires:
This defeats the purpose of storing a refresh token.
Environment
Expected behavior
If Codex has a valid stored
refresh_tokenfor the MCP server, it should automatically refresh the expired access token and continue making authenticated MCP calls without requiring manual CLI login.This is especially important for:
Actual behavior
When the access token expires, Codex starts returning auth failures instead of using the stored refresh token to recover automatically.
Observed failure:
{"success": false, "error": "invalid_grant", "msg": "Authorization required"} ### What steps can reproduce the bug? - Auth to MCP, observe the credentials and refresh token stored in credentials.json - Wait for the token expiry, access the MCP again (prior to refresh token expiry), it will fail on auth and not automatically refresh as it should - Use the CLI to authenticate manually, it will then work again ### What is the expected behavior? Within the refresh token expiry window re-auth should be automatic ### Additional information _No response_