Prepare MCP connections for coordinated OAuth refresh (#42128)

## What changed

- Add the under-development `mcp_oauth_refresh_coordination` feature and pin its selected refresh mode to each MCP connection.
- Treat the refresh mode as part of OAuth connection identity so runtime and MCP configuration refreshes reconnect when the mode changes.
- Keep legacy refresh behavior in builds where coordination is unavailable and emit a warning when coordinated mode is selected.

## Testing

- Cover connection replacement when the feature is toggled through both runtime and MCP configuration refresh paths.

GitOrigin-RevId: 89596150f0338e6ede0e712badecea4450831766
This commit is contained in:
Matthew Zeng authored and copyberry committed 2026-09-01 20:26:57 +00:00
1 parent 7730edf62c
commit bd89ce67cc
15 files changed
+232 -3

No files matched your search

+2
View File
@@ -18,6 +18,7 @@ mod oauth;
mod oauth_callback;
mod oauth_client_registration;
mod oauth_http_client;
mod oauth_refresh_mode;
mod perform_oauth_login;
mod program_resolver;
mod protocol_mode;
@@ -61,6 +62,7 @@ pub use oauth::stored_oauth_credentials;
pub use oauth_callback::McpOAuthCallbackMode;
pub use oauth_callback::resolve_mcp_oauth_callback_url;
pub use oauth_client_registration::McpOAuthClientRegistration;
pub use oauth_refresh_mode::McpOAuthRefreshMode;
pub use perform_oauth_login::OAuthProviderError;
pub use perform_oauth_login::OauthLoginHandle;
pub use perform_oauth_login::perform_oauth_login;
@@ -0,0 +1,11 @@
//! Selects the owner of MCP OAuth refresh and credential persistence.
/// MCP OAuth policy pinned for the lifetime of a connection.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum McpOAuthRefreshMode {
/// Keep Codex's existing refresh and persistence path.
#[default]
Legacy,
/// Let RMCP coordinate refresh through Codex's credential store.
Coordinated,
}