Apply client compatibility to threadless MCP ops

This commit is contained in:
Eric Traut
2026-05-04 15:52:10 -07:00
parent 6a37b1d53e
commit 41f4b83259
3 changed files with 73 additions and 36 deletions

View File

@@ -1195,17 +1195,29 @@ impl MessageProcessor {
}
ClientRequest::McpServerStatusList { params, .. } => {
self.mcp_processor
.mcp_server_status_list(&request_id, params)
.mcp_server_status_list(&request_id, params, client_compatibility_flags)
.await
}
ClientRequest::McpResourceRead { params, .. } => {
self.mcp_processor
.mcp_resource_read(&request_id, params)
.mcp_resource_read(
&request_id,
params,
app_server_client_name.clone(),
client_version.clone(),
client_compatibility_flags,
)
.await
}
ClientRequest::McpServerToolCall { params, .. } => {
self.mcp_processor
.mcp_server_tool_call(&request_id, params)
.mcp_server_tool_call(
&request_id,
params,
app_server_client_name.clone(),
client_version.clone(),
client_compatibility_flags,
)
.await
}
ClientRequest::WindowsSandboxSetupStart { params, .. } => {

View File

@@ -47,8 +47,9 @@ impl McpRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: ListMcpServerStatusParams,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.list_mcp_server_status(request_id, params)
self.list_mcp_server_status(request_id, params, client_compatibility_flags)
.await
.map(|()| None)
}
@@ -57,20 +58,38 @@ impl McpRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: McpResourceReadParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.read_mcp_resource(request_id, params)
.await
.map(|()| None)
self.read_mcp_resource(
request_id,
params,
app_server_client_name,
app_server_client_version,
client_compatibility_flags,
)
.await
.map(|()| None)
}
pub(crate) async fn mcp_server_tool_call(
&self,
request_id: &ConnectionRequestId,
params: McpServerToolCallParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.call_mcp_server_tool(request_id, params)
.await
.map(|()| None)
self.call_mcp_server_tool(
request_id,
params,
app_server_client_name,
app_server_client_version,
client_compatibility_flags,
)
.await
.map(|()| None)
}
async fn mcp_server_refresh_response(
@@ -248,6 +267,7 @@ impl McpRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: ListMcpServerStatusParams,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<(), JSONRPCErrorError> {
let request = request_id.clone();
@@ -271,41 +291,21 @@ impl McpRequestProcessor {
};
tokio::spawn(async move {
Self::list_mcp_server_status_task(
outgoing,
request,
let result = Self::list_mcp_server_status_response(
request.request_id.to_string(),
params,
config,
mcp_config,
auth,
runtime_environment,
client_compatibility_flags,
)
.await;
outgoing.send_result(request, result).await;
});
Ok(())
}
async fn list_mcp_server_status_task(
outgoing: Arc<OutgoingMessageSender>,
request_id: ConnectionRequestId,
params: ListMcpServerStatusParams,
config: Config,
mcp_config: codex_mcp::McpConfig,
auth: Option<CodexAuth>,
runtime_environment: McpRuntimeEnvironment,
) {
let result = Self::list_mcp_server_status_response(
request_id.request_id.to_string(),
params,
config,
mcp_config,
auth,
runtime_environment,
)
.await;
outgoing.send_result(request_id, result).await;
}
async fn list_mcp_server_status_response(
request_id: String,
params: ListMcpServerStatusParams,
@@ -313,6 +313,7 @@ impl McpRequestProcessor {
mcp_config: codex_mcp::McpConfig,
auth: Option<CodexAuth>,
runtime_environment: McpRuntimeEnvironment,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<ListMcpServerStatusResponse, JSONRPCErrorError> {
let detail = match params.detail.unwrap_or(McpServerStatusDetail::Full) {
McpServerStatusDetail::Full => McpSnapshotDetail::Full,
@@ -325,6 +326,7 @@ impl McpRequestProcessor {
request_id,
runtime_environment,
detail,
client_compatibility_flags.mcp_elicitation,
)
.await;
@@ -398,6 +400,9 @@ impl McpRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: McpResourceReadParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<(), JSONRPCErrorError> {
let outgoing = Arc::clone(&self.outgoing);
let McpResourceReadParams {
@@ -408,6 +413,13 @@ impl McpRequestProcessor {
if let Some(thread_id) = thread_id {
let (_, thread) = self.load_thread(&thread_id).await?;
thread
.set_app_server_client_info(
app_server_client_name,
app_server_client_version,
client_compatibility_flags,
)
.await;
let request_id = request_id.clone();
tokio::spawn(async move {
@@ -440,6 +452,7 @@ impl McpRequestProcessor {
runtime_environment,
&server,
&uri,
client_compatibility_flags.mcp_elicitation,
)
.await
.and_then(|result| serde_json::to_value(result).map_err(anyhow::Error::from));
@@ -469,10 +482,20 @@ impl McpRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: McpServerToolCallParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
client_compatibility_flags: ClientCompatibilityFlags,
) -> Result<(), JSONRPCErrorError> {
let outgoing = Arc::clone(&self.outgoing);
let thread_id = params.thread_id.clone();
let (_, thread) = self.load_thread(&thread_id).await?;
thread
.set_app_server_client_info(
app_server_client_name,
app_server_client_version,
client_compatibility_flags,
)
.await;
let meta = with_mcp_tool_call_thread_id_meta(params.meta, &thread_id);
let request_id = request_id.clone();

View File

@@ -231,6 +231,7 @@ pub async fn read_mcp_resource(
runtime_environment: McpRuntimeEnvironment,
server: &str,
uri: &str,
elicitation_compatibility: crate::McpElicitationCompatibility,
) -> anyhow::Result<ReadResourceResult> {
let mut mcp_servers = effective_mcp_servers(config, auth);
mcp_servers.retain(|name, _| name == server);
@@ -255,7 +256,7 @@ pub async fn read_mcp_resource(
codex_apps_tools_cache_key(auth),
tool_plugin_provenance(config),
auth,
crate::McpElicitationCompatibility::default(),
elicitation_compatibility,
)
.await;
@@ -286,6 +287,7 @@ pub async fn collect_mcp_server_status_snapshot_with_detail(
submit_id: String,
runtime_environment: McpRuntimeEnvironment,
detail: McpSnapshotDetail,
elicitation_compatibility: crate::McpElicitationCompatibility,
) -> McpServerStatusSnapshot {
let mcp_servers = effective_mcp_servers(config, auth);
let tool_plugin_provenance = tool_plugin_provenance(config);
@@ -321,7 +323,7 @@ pub async fn collect_mcp_server_status_snapshot_with_detail(
codex_apps_tools_cache_key(auth),
tool_plugin_provenance,
auth,
crate::McpElicitationCompatibility::default(),
elicitation_compatibility,
)
.await;