Files
codex/codex-rs/codex-mcp/src/client_capabilities_tests.rs
mchen-oai 4b0e2a0bff Support MCP form input in full-access user threads (#37864)
## Why

Standard MCP forms can require user-entered values even when tool permissions are
otherwise auto-approved in full-access sessions.

## What changed

- Recognize the `openai/standard-form-input` client extension and surface
  non-approval forms in full-access, user-initiated root threads.
- Keep approval forms, automation and subagent threads, headless sessions, and
  clients without the capability on their existing decline or review paths.
- Treat the capability as client-only so it is not advertised to MCP servers,
  and enable it after session startup so required servers cannot block startup
  waiting for form input.

## Testing

Add unit and app-server coverage for accepted form round trips, declined cases,
approval metadata safeguards, resumed threads, and extension filtering.

GitOrigin-RevId: 053bfe397a5c79eceef90a81d13e2aca6353af43
2026-08-10 18:20:12 +00:00

55 lines
1.5 KiB
Rust

use std::collections::HashMap;
use pretty_assertions::assert_eq;
use serde_json::json;
use super::*;
#[test]
fn selects_only_supported_mcp_extensions() {
let app_ui = json!({
"mimeTypes": [
"text/html;profile=mcp-app",
"text/x-dil;profile=mcp-app",
],
"futureField": {"preserved": true},
});
let extensions = HashMap::from([
(MCP_APP_UI_EXTENSION_ID.to_string(), app_ui.clone()),
(OPENAI_FORM_EXTENSION_ID.to_string(), json!({})),
(
OPENAI_STANDARD_FORM_INPUT_EXTENSION_ID.to_string(),
json!({}),
),
("example/other".to_string(), json!({"enabled": true})),
]);
assert_eq!(
client_mcp_extensions(
Some(&extensions),
/*legacy_openai_form_elicitation*/ false,
),
ClientMcpExtensions::new(HashMap::from([
(MCP_APP_UI_EXTENSION_ID.to_string(), app_ui),
(OPENAI_FORM_EXTENSION_ID.to_string(), json!({})),
(
OPENAI_STANDARD_FORM_INPUT_EXTENSION_ID.to_string(),
json!({}),
),
]))
);
}
#[test]
fn normalizes_legacy_form_capability_into_extensions() {
assert_eq!(
client_mcp_extensions(
/*extensions*/ None, /*legacy_openai_form_elicitation*/ true,
),
ClientMcpExtensions::new(HashMap::from([(
OPENAI_FORM_EXTENSION_ID.to_string(),
json!({}),
)]))
);
}