diff --git a/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-experimental.json.zst b/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-experimental.json.zst index 8677203ab7..b01dad2e54 100644 Binary files a/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-experimental.json.zst and b/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-experimental.json.zst differ diff --git a/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-stable.json.zst b/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-stable.json.zst index d3a6360edc..dcde22237b 100644 Binary files a/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-stable.json.zst and b/codex-rs/app-server-protocol/schema/precomputed/app-server-exports-stable.json.zst differ diff --git a/codex-rs/app-server-protocol/src/protocol/v2/mcp.rs b/codex-rs/app-server-protocol/src/protocol/v2/mcp.rs index a4cc385e49..44b217b4c6 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2/mcp.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2/mcp.rs @@ -758,6 +758,9 @@ pub enum McpServerElicitationRequest { #[serde(rename = "openai/userVerification", rename_all = "camelCase")] #[ts(rename = "openai/userVerification", rename_all = "camelCase")] UserVerification { + #[serde(rename = "_meta")] + #[ts(rename = "_meta")] + meta: Option, title: String, description: String, challenge: String, @@ -808,10 +811,12 @@ impl TryFrom for McpServerElicitationRequest { fn try_from(value: CoreElicitationRequest) -> Result { match value { CoreElicitationRequest::UserVerification { + meta, title, description, challenge, } => Ok(Self::UserVerification { + meta, title, description, challenge, diff --git a/codex-rs/app-server-protocol/src/protocol/v2/tests.rs b/codex-rs/app-server-protocol/src/protocol/v2/tests.rs index 564fed25a3..d0f9401d79 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2/tests.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2/tests.rs @@ -2323,6 +2323,41 @@ fn mcp_server_elicitation_request_from_core_url_request() { ); } +#[test] +fn mcp_server_user_verification_metadata_round_trips_from_core() { + for meta in [ + None, + Some(json!({"example/display": {"label": "Operation"}})), + ] { + let mut wire = json!({ + "mode": "openai/userVerification", + "title": "Approve", + "description": "Review operation", + "challenge": "AQID", + }); + if let Some(meta) = &meta { + wire["_meta"] = meta.clone(); + } + let core: CoreElicitationRequest = serde_json::from_value(wire.clone()).unwrap(); + let request = McpServerElicitationRequest::try_from(core).unwrap(); + assert_eq!( + request, + McpServerElicitationRequest::UserVerification { + meta: meta.clone(), + title: "Approve".into(), + description: "Review operation".into(), + challenge: "AQID".into(), + } + ); + assert_eq!( + serde_json::from_value::(wire.clone()).unwrap(), + request + ); + wire["_meta"] = json!(meta); + assert_eq!(serde_json::to_value(request).unwrap(), wire); + } +} + #[test] fn mcp_server_elicitation_request_from_core_form_request() { let request = McpServerElicitationRequest::try_from(CoreElicitationRequest::Form { diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md index 5206ea6368..be16b5d1c5 100644 --- a/codex-rs/app-server/README.md +++ b/codex-rs/app-server/README.md @@ -96,6 +96,12 @@ Before sending verification requests to desktop sessions, deploy a GUI that handles the typed verification request, cancellation, and late proofs. The general `experimentalApi` opt-in does not identify a compatible GUI version. +Native `openai/userVerification` elicitation requests preserve optional `_meta` +JSON through MCP transport and `mcpServer/elicitation/request`. Clients may use +this metadata for extension-specific presentation and must continue to accept +requests without it. Metadata does not change the challenge bytes or the proof +returned in the acceptance response. + Local UI clients use five methods. They require the existing `experimentalApi` opt-in. The local provider reports `unavailable/providerUnavailable` on unsupported platforms or without the required diff --git a/codex-rs/app-server/src/user_verification_activation_tests.rs b/codex-rs/app-server/src/user_verification_activation_tests.rs index 8de777c51b..336a581292 100644 --- a/codex-rs/app-server/src/user_verification_activation_tests.rs +++ b/codex-rs/app-server/src/user_verification_activation_tests.rs @@ -78,6 +78,7 @@ async fn user_verification_initialize_owns_advertisement_and_eligibility() -> Re turn_id: None, server_name: "codex_apps".into(), request: rpc::McpServerElicitationRequest::UserVerification { + meta: None, challenge: "AQ".into(), title: "Approve".into(), description: String::new(), diff --git a/codex-rs/app-server/src/user_verification_connection_tests.rs b/codex-rs/app-server/src/user_verification_connection_tests.rs index 08a42a43e9..15ad705e54 100644 --- a/codex-rs/app-server/src/user_verification_connection_tests.rs +++ b/codex-rs/app-server/src/user_verification_connection_tests.rs @@ -24,6 +24,7 @@ fn request() -> rpc::ServerRequestPayload { turn_id: None, server_name: "codex_apps".into(), request: rpc::McpServerElicitationRequest::UserVerification { + meta: None, title: "Approve".into(), description: String::new(), challenge: "AQ".into(), diff --git a/codex-rs/app-server/src/user_verification_ownership_tests.rs b/codex-rs/app-server/src/user_verification_ownership_tests.rs index a2a0e04d5f..219868795a 100644 --- a/codex-rs/app-server/src/user_verification_ownership_tests.rs +++ b/codex-rs/app-server/src/user_verification_ownership_tests.rs @@ -18,6 +18,7 @@ fn request(thread_id: ThreadId) -> ServerRequestPayload { turn_id: Some("turn-1".into()), server_name: "plugin-service".into(), request: McpServerElicitationRequest::UserVerification { + meta: None, title: "Approve".into(), description: String::new(), challenge: "AQID".into(), diff --git a/codex-rs/app-server/tests/suite/v2/user_verification_mcp.rs b/codex-rs/app-server/tests/suite/v2/user_verification_mcp.rs index 86609db01b..d40ea7a89e 100644 --- a/codex-rs/app-server/tests/suite/v2/user_verification_mcp.rs +++ b/codex-rs/app-server/tests/suite/v2/user_verification_mcp.rs @@ -99,6 +99,7 @@ impl ServerHandler for VerificationServer { "title": "Approve purchase", "description": "Pay $200 to Example Store", "challenge": "AAECA_7_", + "_meta": {"example/display": {"label": "Operation"}}, })), ))) .await @@ -182,6 +183,7 @@ async fn user_verification_mcp_round_trip_requires_proof_in_full_access() -> Res assert_eq!( request.request, ElicitationRequest::UserVerification { + meta: Some(json!({"example/display": {"label": "Operation"}})), title: "Approve purchase".into(), description: "Pay $200 to Example Store".into(), challenge: "AAECA_7_".into(), diff --git a/codex-rs/codex-mcp/src/elicitation.rs b/codex-rs/codex-mcp/src/elicitation.rs index c27e6ce54a..970794098a 100644 --- a/codex-rs/codex-mcp/src/elicitation.rs +++ b/codex-rs/codex-mcp/src/elicitation.rs @@ -291,6 +291,7 @@ impl ElicitationRequestManager { .ok() .and_then(|authority| authority.clone()); if let Elicitation::UserVerification { + meta, title, description, challenge, @@ -309,6 +310,7 @@ impl ElicitationRequestManager { authority, server_name, ElicitationRequest::UserVerification { + meta, title, description, challenge, diff --git a/codex-rs/codex-mcp/src/elicitation_tests.rs b/codex-rs/codex-mcp/src/elicitation_tests.rs index 8c6a31183d..3e859cd0e1 100644 --- a/codex-rs/codex-mcp/src/elicitation_tests.rs +++ b/codex-rs/codex-mcp/src/elicitation_tests.rs @@ -604,6 +604,7 @@ async fn user_verification_requires_the_app_even_when_policy_would_approve_or_de let pending = tokio::spawn(sender( RequestId::Number(7), Elicitation::UserVerification { + meta: Some(json!({"example/display": {"label": "Operation"}})), title: "Approve purchase".into(), description: "Pay $200".into(), challenge: "AQID".into(), @@ -616,6 +617,7 @@ async fn user_verification_requires_the_app_even_when_policy_would_approve_or_de assert_eq!( request.request, ElicitationRequest::UserVerification { + meta: Some(json!({"example/display": {"label": "Operation"}})), title: "Approve purchase".into(), description: "Pay $200".into(), challenge: "AQID".into(), @@ -665,6 +667,7 @@ async fn user_verification_cancels_when_no_app_can_receive_the_request() { sender( RequestId::Number(7), Elicitation::UserVerification { + meta: None, title: "Approve".into(), description: String::new(), challenge: "AQID".into(), @@ -694,6 +697,7 @@ async fn user_verification_cancels_for_an_event_receiver_without_host_activation sender( RequestId::Number(7), Elicitation::UserVerification { + meta: None, title: "Approve".into(), description: String::new(), challenge: "AQID".into(), @@ -734,6 +738,7 @@ async fn user_verification_drops_pending_response_when_the_request_is_cancelled( let pending = tokio::spawn(sender( RequestId::Number(7), Elicitation::UserVerification { + meta: None, title: "Approve".into(), description: String::new(), challenge: "AQID".into(), @@ -779,6 +784,7 @@ async fn user_verification_rejects_attached_servers_even_if_they_use_the_plugin_ sender( RequestId::Number(7), Elicitation::UserVerification { + meta: None, title: "Approve".into(), description: String::new(), challenge: "AQID".into() diff --git a/codex-rs/core/src/session/turn_tests.rs b/codex-rs/core/src/session/turn_tests.rs index e43fb6a2ae..40faa0bd78 100644 --- a/codex-rs/core/src/session/turn_tests.rs +++ b/codex-rs/core/src/session/turn_tests.rs @@ -95,6 +95,7 @@ fn realtime_user_verification_notice_excludes_request_payload() { server_name: "private-server-name".to_string(), id: codex_protocol::mcp::RequestId::String("private-request-id".to_string()), request: codex_protocol::approvals::ElicitationRequest::UserVerification { + meta: None, title: "private-title".to_string(), description: "private-description".to_string(), challenge: "private-challenge".to_string(), diff --git a/codex-rs/core/tests/suite/mcp_extension_protocol.rs b/codex-rs/core/tests/suite/mcp_extension_protocol.rs index f57cdb3d50..0f66d9f6ac 100644 --- a/codex-rs/core/tests/suite/mcp_extension_protocol.rs +++ b/codex-rs/core/tests/suite/mcp_extension_protocol.rs @@ -271,6 +271,7 @@ async fn hosted_apps_protocol_override_preserves_native_verification() -> anyhow assert_eq!( request.request, ElicitationRequest::UserVerification { + meta: None, title: "Verify action".into(), description: "Verify the requested operation".into(), challenge: "AQID".into(), diff --git a/codex-rs/protocol/src/approvals.rs b/codex-rs/protocol/src/approvals.rs index 30ace64f8a..3ef28481b5 100644 --- a/codex-rs/protocol/src/approvals.rs +++ b/codex-rs/protocol/src/approvals.rs @@ -405,6 +405,9 @@ pub enum ElicitationRequest { #[serde(rename = "openai/userVerification")] #[ts(rename = "openai/userVerification")] UserVerification { + #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")] + #[ts(optional, rename = "_meta")] + meta: Option, title: String, description: String, challenge: String, diff --git a/codex-rs/rmcp-client/src/elicitation_client_service.rs b/codex-rs/rmcp-client/src/elicitation_client_service.rs index 497ca0652d..2ef94e2fbe 100644 --- a/codex-rs/rmcp-client/src/elicitation_client_service.rs +++ b/codex-rs/rmcp-client/src/elicitation_client_service.rs @@ -381,12 +381,13 @@ fn restore_context_meta( } match &mut request { - Elicitation::UserVerification { .. } => {} Elicitation::Mcp(request) => request .meta_mut() .get_or_insert_with(RequestMetaObject::new) .extend(context_meta), - Elicitation::OpenAiForm { meta, .. } | Elicitation::OpenAiElicitationForm { meta, .. } => { + Elicitation::OpenAiForm { meta, .. } + | Elicitation::OpenAiElicitationForm { meta, .. } + | Elicitation::UserVerification { meta, .. } => { let meta = meta .get_or_insert_with(|| Value::Object(Map::new())) .as_object_mut(); diff --git a/codex-rs/rmcp-client/src/rmcp_client.rs b/codex-rs/rmcp-client/src/rmcp_client.rs index 6d50c63d9c..1bb4970bb4 100644 --- a/codex-rs/rmcp-client/src/rmcp_client.rs +++ b/codex-rs/rmcp-client/src/rmcp_client.rs @@ -319,6 +319,7 @@ pub enum Elicitation { requested_schema: serde_json::Value, }, UserVerification { + meta: Option, title: String, description: String, challenge: String, @@ -329,10 +330,11 @@ impl Elicitation { pub fn meta(&self) -> Option<&serde_json::Map> { match self { Self::Mcp(request) => request.meta().map(|meta| &meta.0.0), - Self::OpenAiForm { meta, .. } | Self::OpenAiElicitationForm { meta, .. } => { + Self::OpenAiForm { meta, .. } + | Self::OpenAiElicitationForm { meta, .. } + | Self::UserVerification { meta, .. } => { meta.as_ref().and_then(serde_json::Value::as_object) } - Self::UserVerification { .. } => None, } } } diff --git a/codex-rs/rmcp-client/src/user_verification.rs b/codex-rs/rmcp-client/src/user_verification.rs index fb93b42ff6..50806c08f6 100644 --- a/codex-rs/rmcp-client/src/user_verification.rs +++ b/codex-rs/rmcp-client/src/user_verification.rs @@ -15,6 +15,8 @@ pub(crate) const MODE: &str = "openai/userVerification"; #[serde(rename_all = "camelCase", deny_unknown_fields)] struct RequestParams { mode: String, + #[serde(rename = "_meta")] + meta: Option>, title: String, description: String, challenge: String, @@ -42,6 +44,7 @@ pub(crate) fn parse_request(request: CustomRequest) -> Result ElicitationClientService { ) } +#[tokio::test] +async fn user_verification_dispatch_preserves_context_metadata() -> anyhow::Result<()> { + let mut service = service(); + service.send_elicitation = Arc::new(Box::new(|_, request| { + assert_eq!( + request, + Elicitation::UserVerification { + meta: Some(json!({"example/display": {"label": "Operation"}})), + title: "Approve".into(), + description: "Review operation".into(), + challenge: "AQID".into(), + } + ); + Box::pin(async { + Ok(ElicitationResponse { + action: ElicitationAction::Cancel, + content: None, + meta: None, + }) + }) + })); + let (client_transport, server_transport) = tokio::io::duplex(/*max_buf_size*/ 4096); + let client = serve_directly(service, client_transport, /*peer_info*/ None); + let mut server = IntoTransport::::into_transport(server_transport); + server + .send(serde_json::from_value::(json!({ + "jsonrpc": "2.0", "id": 1, "method": OPENAI_ELICITATION_METHOD, + "params": { + "mode": crate::user_verification::MODE, + "title": "Approve", "description": "Review operation", "challenge": "AQID", + "_meta": {"progressToken": 7, "example/display": {"label": "Operation"}} + } + }))?) + .await?; + let response = timeout(Duration::from_secs(/*secs*/ 5), server.receive()) + .await? + .unwrap(); + assert_eq!( + serde_json::to_value(response)?, + json!({"jsonrpc": "2.0", "id": 1, "result": {"action": "cancel"}}) + ); + client.cancel().await?; + Ok(()) +} + #[tokio::test] async fn user_verification_remembers_cancellation_before_request_handler_runs() -> anyhow::Result<()> { diff --git a/codex-rs/rmcp-client/src/user_verification_tests.rs b/codex-rs/rmcp-client/src/user_verification_tests.rs index 1465f041dc..628dbfc5a5 100644 --- a/codex-rs/rmcp-client/src/user_verification_tests.rs +++ b/codex-rs/rmcp-client/src/user_verification_tests.rs @@ -16,6 +16,7 @@ fn user_verification_request_preserves_signed_bytes_and_display_text() { )) .unwrap(), Elicitation::UserVerification { + meta: None, title: "Approve purchase".to_string(), description: "Pay $200 to Example Store".to_string(), challenge: "AQID".to_string(), @@ -23,6 +24,54 @@ fn user_verification_request_preserves_signed_bytes_and_display_text() { ); } +#[test] +fn user_verification_request_metadata_matches_mcp_elicitation() { + for meta in [ + None, + Some(json!(null)), + Some(json!({})), + Some(json!({"example/display": {"label": "Operation", "details": [1, true, null]}})), + Some(json!(true)), + Some(json!(7)), + Some(json!("scalar")), + Some(json!([])), + ] { + let mut params = json!({ + "mode": MODE, + "title": "Approve", + "description": "Review operation", + "challenge": "AQID", + }); + let mut mcp_params = json!({ + "mode": "form", + "message": "Approve", + "requestedSchema": {"type": "object", "properties": {}}, + }); + if let Some(meta) = &meta { + params["_meta"] = meta.clone(); + mcp_params["_meta"] = meta.clone(); + } + let mcp_request = serde_json::from_value::(mcp_params); + let expected = if mcp_request.is_ok() { + Ok(Elicitation::UserVerification { + meta: meta.filter(serde_json::Value::is_object), + title: "Approve".into(), + description: "Review operation".into(), + challenge: "AQID".into(), + }) + } else { + Err(invalid_request()) + }; + assert_eq!( + parse_request(CustomRequest::new( + "openai/elicitation/create", + Some(params), + )), + expected, + ); + } +} + #[test] fn user_verification_rejects_invalid_or_unbounded_requests_without_echoing_values() { for (field, value) in [ diff --git a/codex-rs/rmcp-client/tests/mcp_2026_mrtr/native_verification_tests.rs b/codex-rs/rmcp-client/tests/mcp_2026_mrtr/native_verification_tests.rs index 8f26c64986..91890e8269 100644 --- a/codex-rs/rmcp-client/tests/mcp_2026_mrtr/native_verification_tests.rs +++ b/codex-rs/rmcp-client/tests/mcp_2026_mrtr/native_verification_tests.rs @@ -13,7 +13,8 @@ fn native_request() -> Value { "method": "openai/elicitation/create", "params": { "mode": "openai/userVerification", "title": "Verify action", - "description": "Verify the requested operation", "challenge": "AQID" + "description": "Verify the requested operation", "challenge": "AQID", + "_meta": {"example/display": {"label": "Operation"}} } }) } @@ -206,6 +207,7 @@ async fn native_mrtr_returns_validated_proof_or_cancellation_in_content() -> any assert_eq!( request, Elicitation::UserVerification { + meta: Some(json!({"example/display": {"label": "Operation"}})), title: "Verify action".into(), description: "Verify the requested operation".into(), challenge: "AQID".into(), diff --git a/codex-rs/tui/src/app/pending_interactive_replay.rs b/codex-rs/tui/src/app/pending_interactive_replay.rs index 366591569b..11c39a90e3 100644 --- a/codex-rs/tui/src/app/pending_interactive_replay.rs +++ b/codex-rs/tui/src/app/pending_interactive_replay.rs @@ -928,6 +928,7 @@ mod tests { && let ServerRequest::McpServerElicitationRequest { params, .. } = &mut request { params.request = McpServerElicitationRequest::UserVerification { + meta: None, title: "Verify".to_string(), description: "Approve deployment".to_string(), challenge: "AQID".to_string(), diff --git a/codex-rs/tui/src/app/tests/user_verification_routes_tests.rs b/codex-rs/tui/src/app/tests/user_verification_routes_tests.rs index 95d00bbcfc..6fcd5a22b5 100644 --- a/codex-rs/tui/src/app/tests/user_verification_routes_tests.rs +++ b/codex-rs/tui/src/app/tests/user_verification_routes_tests.rs @@ -9,6 +9,7 @@ fn user_verification_server_request(thread_id: ThreadId, request_id: i64) -> Ser turn_id: Some("turn-verification".to_string()), server_name: "deployments".to_string(), request: McpServerElicitationRequest::UserVerification { + meta: None, title: "Approve deployment?".to_string(), description: "Verify the production deployment.".to_string(), challenge: "AQID".to_string(), diff --git a/codex-rs/tui/src/app/user_verification_requests.rs b/codex-rs/tui/src/app/user_verification_requests.rs index dcbe7484bd..daf6ab0024 100644 --- a/codex-rs/tui/src/app/user_verification_requests.rs +++ b/codex-rs/tui/src/app/user_verification_requests.rs @@ -44,6 +44,7 @@ impl UserVerificationRequests { title, description, challenge, + .. } = ¶ms.request { self.pending.insert( diff --git a/codex-rs/tui/src/app/user_verification_requests_tests.rs b/codex-rs/tui/src/app/user_verification_requests_tests.rs index 19234b203c..2a4cd410db 100644 --- a/codex-rs/tui/src/app/user_verification_requests_tests.rs +++ b/codex-rs/tui/src/app/user_verification_requests_tests.rs @@ -19,6 +19,7 @@ fn verification_request() -> ServerRequest { turn_id: None, server_name: "deployments".to_string(), request: McpServerElicitationRequest::UserVerification { + meta: None, title: "Approve deployment?".to_string(), description: "Deploy the reviewed change.".to_string(), challenge: "AQID".to_string(), diff --git a/codex-rs/tui/src/app/user_verification_tests.rs b/codex-rs/tui/src/app/user_verification_tests.rs index a3c6e1985e..64d1e97ced 100644 --- a/codex-rs/tui/src/app/user_verification_tests.rs +++ b/codex-rs/tui/src/app/user_verification_tests.rs @@ -16,6 +16,7 @@ fn verification_request() -> ServerRequest { turn_id: None, server_name: "deployments".to_string(), request: McpServerElicitationRequest::UserVerification { + meta: None, title: "Approve deployment?".to_string(), description: "Deploy the reviewed change.".to_string(), challenge: "AQID".to_string(),