mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Simplify Xcode MCP compatibility plumbing
This commit is contained in:
@@ -202,7 +202,6 @@ impl McpConnectionManager {
|
||||
cancel_token.clone(),
|
||||
tx_event.clone(),
|
||||
elicitation_requests.clone(),
|
||||
elicitation_compatibility,
|
||||
codex_apps_tools_cache_context,
|
||||
Arc::clone(&tool_plugin_provenance),
|
||||
runtime_environment.clone(),
|
||||
|
||||
@@ -283,10 +283,6 @@ async fn codex_apps_only_custom_server_elicitation_is_declined_without_event() {
|
||||
meta: None,
|
||||
message: "What should I say?".to_string(),
|
||||
requested_schema: rmcp::model::ElicitationSchema::builder()
|
||||
.required_property(
|
||||
"message",
|
||||
rmcp::model::PrimitiveSchema::String(rmcp::model::StringSchema::new()),
|
||||
)
|
||||
.build()
|
||||
.expect("schema should build"),
|
||||
},
|
||||
@@ -294,14 +290,8 @@ async fn codex_apps_only_custom_server_elicitation_is_declined_without_event() {
|
||||
.await
|
||||
.expect("elicitation should auto decline");
|
||||
|
||||
assert_eq!(
|
||||
response,
|
||||
ElicitationResponse {
|
||||
action: ElicitationAction::Decline,
|
||||
content: None,
|
||||
meta: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(response.action, ElicitationAction::Decline);
|
||||
assert_eq!(response.content, None);
|
||||
assert!(matches!(
|
||||
rx_event.try_recv(),
|
||||
Err(async_channel::TryRecvError::Empty)
|
||||
@@ -846,7 +836,6 @@ fn elicitation_capability_uses_2025_06_18_shape_for_all_servers() {
|
||||
for server_name in [CODEX_APPS_MCP_SERVER_NAME, "custom_mcp"] {
|
||||
let capability =
|
||||
elicitation_capability_for_server(server_name, McpElicitationCompatibility::Default);
|
||||
assert_eq!(capability, Some(ElicitationCapability::default()));
|
||||
assert_eq!(
|
||||
serde_json::to_value(capability).expect("serialize elicitation capability"),
|
||||
serde_json::json!({})
|
||||
@@ -855,16 +844,14 @@ fn elicitation_capability_uses_2025_06_18_shape_for_all_servers() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_only_elicitation_capability_keeps_codex_apps_enabled() {
|
||||
fn codex_apps_only_elicitation_capability_suppresses_custom_servers() {
|
||||
let compatibility = McpElicitationCompatibility::CodexAppsOnly;
|
||||
assert_eq!(
|
||||
elicitation_capability_for_server(
|
||||
CODEX_APPS_MCP_SERVER_NAME,
|
||||
McpElicitationCompatibility::CodexAppsOnly,
|
||||
),
|
||||
elicitation_capability_for_server(CODEX_APPS_MCP_SERVER_NAME, compatibility),
|
||||
Some(ElicitationCapability::default())
|
||||
);
|
||||
assert_eq!(
|
||||
elicitation_capability_for_server("custom_mcp", McpElicitationCompatibility::CodexAppsOnly,),
|
||||
elicitation_capability_for_server("custom_mcp", compatibility),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
@@ -191,14 +191,15 @@ impl ElicitationRequestManager {
|
||||
.boxed()
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn compatibility(&self) -> McpElicitationCompatibility {
|
||||
self.compatibility
|
||||
}
|
||||
}
|
||||
|
||||
/// Compatibility policy for the MCP elicitation capability surface.
|
||||
///
|
||||
/// The default behavior advertises MCP elicitation support to every server.
|
||||
/// `CodexAppsOnly` preserves the pre-PR #17043 capability surface by keeping
|
||||
/// support for the built-in `codex_apps` server while suppressing support for
|
||||
/// custom MCP servers.
|
||||
/// `CodexAppsOnly` preserves the pre-PR #17043 behavior for old clients by
|
||||
/// keeping support for `codex_apps` while suppressing custom MCP servers.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub enum McpElicitationCompatibility {
|
||||
#[default]
|
||||
@@ -207,7 +208,7 @@ pub enum McpElicitationCompatibility {
|
||||
}
|
||||
|
||||
impl McpElicitationCompatibility {
|
||||
pub(crate) fn allows_server_elicitation(self, server_name: &str) -> bool {
|
||||
pub fn allows_server_elicitation(self, server_name: &str) -> bool {
|
||||
match self {
|
||||
Self::Default => true,
|
||||
Self::CodexAppsOnly => server_name == CODEX_APPS_MCP_SERVER_NAME,
|
||||
|
||||
@@ -139,7 +139,6 @@ impl AsyncManagedClient {
|
||||
cancel_token: CancellationToken,
|
||||
tx_event: Sender<Event>,
|
||||
elicitation_requests: ElicitationRequestManager,
|
||||
elicitation_compatibility: McpElicitationCompatibility,
|
||||
codex_apps_tools_cache_context: Option<CodexAppsToolsCacheContext>,
|
||||
tool_plugin_provenance: Arc<ToolPluginProvenance>,
|
||||
runtime_environment: McpRuntimeEnvironment,
|
||||
@@ -182,7 +181,6 @@ impl AsyncManagedClient {
|
||||
tool_filter: startup_tool_filter,
|
||||
tx_event,
|
||||
elicitation_requests,
|
||||
elicitation_compatibility,
|
||||
codex_apps_tools_cache_context,
|
||||
},
|
||||
)
|
||||
@@ -466,10 +464,10 @@ async fn start_server_task(
|
||||
tool_filter,
|
||||
tx_event,
|
||||
elicitation_requests,
|
||||
elicitation_compatibility,
|
||||
codex_apps_tools_cache_context,
|
||||
} = params;
|
||||
let elicitation = elicitation_capability_for_server(&server_name, elicitation_compatibility);
|
||||
let elicitation =
|
||||
elicitation_capability_for_server(&server_name, elicitation_requests.compatibility());
|
||||
let params = InitializeRequestParams {
|
||||
meta: None,
|
||||
capabilities: ClientCapabilities {
|
||||
@@ -552,7 +550,6 @@ struct StartServerTaskParams {
|
||||
tool_filter: ToolFilter,
|
||||
tx_event: Sender<Event>,
|
||||
elicitation_requests: ElicitationRequestManager,
|
||||
elicitation_compatibility: McpElicitationCompatibility,
|
||||
codex_apps_tools_cache_context: Option<CodexAppsToolsCacheContext>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user