codex icon indicating copy to clipboard operation
codex copied to clipboard

Feature Request: Support dynamic reloading of MCP HTTP headers on auth failure (401/403)

Open jdsalasca opened this issue 1 year ago • 6 comments

What feature would you like to see?

Context

I am using an MCP server that requires a custom authentication header (e.g., a Bearer token) defined in the config.toml. Currently, my configuration looks like this:

[mcp_servers.enterprise_mcp]
transport = "http"
url = "https://enterprise_[mcp-mcp.enterprisedomain.com/mcp](https://mcp-mcp.enterprisedomain.com/mcp)"
startup_timeout_sec = 30
[mcp_servers.enterprise_mcp.http_headers]
x-token = "Bearer {{token}}"

The Problem

The authentication tokens for my enterprise environment expire every 3 hours. When a token expires, the MCP connection fails. Although I can update the token in config.toml, the current session (Codex) does not detect this change or reload the connection parameters.

Current Workaround & Impact To restore connectivity, I am forced to kill and restart the entire Codex session.

This causes a complete loss of chat context and history.

I have to start my workflow from scratch every 3 hours.

This creates significant friction and limits the usability of MCP for long-running tasks.

Proposed Solution I would like to request a feature that handles authentication failures gracefully without killing the session. Specifically:

Detect Failure: If the MCP server responds with a 401 Unauthorized or 403 Forbidden.

Check Config: The system should check if config.toml has been modified since the last load.

Hot Reload: If the config has changed (e.g., a new token was pasted), automatically reload the MCP connection/headers.

User Prompt: If the config hasn't changed, prompt the user to update their credentials.

This would vastly improve the developer experience for users working with secure, short-lived token environments.

Thanks!

Additional information

No response

jdsalasca avatar Nov 26 '25 15:11 jdsalasca

This has to be considered a bug too

jdsalasca avatar Nov 28 '25 02:11 jdsalasca

/exit codex resume

jbranc avatar Jan 09 '26 23:01 jbranc

yeah like we can do that: kill a conversation and resume it, agree but still so much steps for something that even sometimes could be entirely done by the mcp, It has to be done automatically without the neccesity to kill and restart the conversation

jdsalasca avatar Jan 11 '26 20:01 jdsalasca

yes for sure - i agree this is a Bug not a feature request. the atlassian-rovo mcp will actually expire during a long execution run of the model, and therefore not be able to complete its task at the end until you reauth. its not ok.

jbranc avatar Jan 11 '26 21:01 jbranc

Token expiry forcing full session restarts highlights the fragility of session-based authentication for MCP. MCPS (MCP Secure) takes a different approach — per-message signing with ECDSA P-256 agent passports. Each message is independently verifiable (nonce + timestamp + message_hash + signature), so there is no session token to expire or refresh.

The agent holds a cryptographic passport (valid for up to 365 days, revocable in real-time via Trust Authority) and signs every JSON-RPC message individually. No OAuth callbacks, no token refresh, no session state to manage.

Published as an IETF Internet-Draft and available on npm as mcp-secure (zero dependencies).

razashariff avatar Mar 16 '26 13:03 razashariff

Or, even better, provide support for something like claude code's headersHelper config option.

lukeyeager avatar Jul 28 '26 18:07 lukeyeager