Clarify MCP OAuth reauthentication errors (#38418)

## Why

When an MCP server rejects existing OAuth credentials, reporting that the server
is merely not logged in obscures that the user needs to authenticate again.

## What changed

Pass the MCP startup failure reason into error formatting and report that the
server requires OAuth reauthentication when appropriate. Preserve the existing
recovery hint for either `codex mcp login` or the client's OAuth sign-in flow.

## Testing

Cover the reauthentication message for both login flows and verify it in the
streamable HTTP OAuth round-trip test.

GitOrigin-RevId: 6f6d5fe7519b1a476f8b70d976223b2ea1ec938e
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-13 18:45:13 +00:00
1 parent 4f7032173e
commit f8a3db0b99
4 files changed
+90 -28

No files matched your search

+8 -5
View File
@@ -413,17 +413,19 @@ impl McpConnectionSet {
},
);
if let Some(error) = unchanged_auth_failure {
let reason = connection_identity
.oauth_credentials()
.ok()
.flatten()
.map(|_| McpStartupFailureReason::ReauthenticationRequired);
let status = McpStartupStatus::Failed {
error: mcp_init_error_display(
&server_name,
Some(&configured_config),
&error,
reason,
),
reason: connection_identity
.oauth_credentials()
.ok()
.flatten()
.map(|_| McpStartupFailureReason::ReauthenticationRequired),
reason,
};
let tx_event = tx_event.clone();
let submit_id = startup_submit_id.clone();
@@ -603,6 +605,7 @@ impl McpConnectionSet {
server_name.as_str(),
Some(&configured_config),
error,
reason,
);
McpStartupStatus::Failed {
error: error_str,