mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
Add attributed MCP OAuth credential storage telemetry (#49392)
## What changed - Instrument MCP OAuth loads, saves, deletes, fallback cleanup, and refresh persistence with credential-free storage metrics, distinguishing configured policy from operations on a pinned store. - Retain the originating client across background tasks, blocking storage operations, and session recovery, including recovery after startup found no credentials. - Preserve typed keyring and lock error categories for metrics and remove raw error details from storage warnings. ## Testing Add tests for policy and pinned-store outcomes, best-effort cleanup failures, wrapped lock errors, and successful or failed refresh persistence without duplicate observations. Add recovery tests that verify client attribution after anonymous startup and across threads with different originators. GitOrigin-RevId: 5ea4528bcdcf500c8ffdf1d9c7008ea52112c726
This commit is contained in:
@@ -11,6 +11,7 @@ use codex_mcp::ElicitationReviewRequest;
|
||||
use codex_mcp::ElicitationReviewer;
|
||||
use codex_mcp::ElicitationReviewerHandle;
|
||||
use codex_mcp::MCP_TOOL_CODEX_APPS_META_KEY;
|
||||
use codex_otel::auth_storage::AuthStorageOriginator;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_protocol::capabilities::CapabilityRootLocation;
|
||||
use codex_protocol::capabilities::SelectedCapabilityRoot;
|
||||
@@ -343,7 +344,9 @@ impl Session {
|
||||
input.mcp_servers.contains_key(CODEX_APPS_MCP_SERVER_NAME),
|
||||
"unknown MCP server '{CODEX_APPS_MCP_SERVER_NAME}'"
|
||||
);
|
||||
let refreshed = self.services.mcp_runtime.replace_fresh(input).await;
|
||||
let refreshed = AuthStorageOriginator::from_client_name(&desired.originator)
|
||||
.scope(self.services.mcp_runtime.replace_fresh(input))
|
||||
.await;
|
||||
self.services.thread_extension_data.insert(selected_plugins);
|
||||
refreshed
|
||||
}
|
||||
@@ -375,11 +378,14 @@ impl Session {
|
||||
self.mark_mcp_runtime_dirty();
|
||||
}
|
||||
|
||||
let recovered_oauth_servers = self
|
||||
.services
|
||||
.mcp_runtime
|
||||
.updated_oauth_credentials_after_auth_failure()
|
||||
.await;
|
||||
let recovered_oauth_servers =
|
||||
AuthStorageOriginator::from_client_name(&turn_context.originator)
|
||||
.scope(
|
||||
self.services
|
||||
.mcp_runtime
|
||||
.updated_oauth_credentials_after_auth_failure(),
|
||||
)
|
||||
.await;
|
||||
if !recovered_oauth_servers.is_empty()
|
||||
&& let Ok(_refresh) = self.mcp_refresh.acquire().await
|
||||
&& self
|
||||
|
||||
@@ -16,6 +16,7 @@ use codex_mcp::McpServerSource;
|
||||
use codex_mcp::McpStartupPolicy;
|
||||
use codex_mcp::PreparedMcpCall;
|
||||
use codex_mcp::ToolInfo;
|
||||
use codex_otel::auth_storage::AuthStorageOriginator;
|
||||
use codex_protocol::capabilities::SelectedCapabilityRoot;
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -300,7 +301,9 @@ impl Session {
|
||||
ready_selected_capability_roots,
|
||||
elicitation_reviewer,
|
||||
);
|
||||
self.services.mcp_runtime.replace(input).await;
|
||||
AuthStorageOriginator::from_client_name(&desired.originator)
|
||||
.scope(self.services.mcp_runtime.replace(input))
|
||||
.await;
|
||||
self.services.thread_extension_data.insert(selected_plugins);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user