mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
Scope MCP resource reads by connector (#39244)
## What changed - Add an optional `connectorId` to `mcpServer/resource/read`. - Forward the selected connector through `x-codex-turn-metadata` for threaded and threadless resource reads, restricting hosted app resources to that connector. - Update the generated protocol schemas and app-server documentation. GitOrigin-RevId: 5cc94d703abbbb6086665910c1c9ed5dc7075210
This commit is contained in:
1 parent
19d185fec8
commit
a1dc95d5af
17 files changed
+69
-12
No files matched your search
@@ -1,6 +1,7 @@
|
||||
use super::*;
|
||||
use codex_core::McpManager;
|
||||
use codex_mcp::McpServerSource;
|
||||
use codex_mcp::ReadResourceRequestParams;
|
||||
|
||||
const MCP_TOOL_THREAD_ID_META_KEY: &str = "threadId";
|
||||
|
||||
@@ -425,7 +426,22 @@ impl McpRequestProcessor {
|
||||
origin_call_id,
|
||||
server,
|
||||
uri,
|
||||
connector_id,
|
||||
} = params;
|
||||
let mut resource_params = ReadResourceRequestParams::new(uri);
|
||||
if let Some(connector_id) = connector_id {
|
||||
resource_params.meta = Some(
|
||||
serde_json::Map::from_iter([(
|
||||
"x-codex-turn-metadata".to_string(),
|
||||
serde_json::json!({
|
||||
"mcp_request_meta": {
|
||||
"selected_connector_ids": [connector_id],
|
||||
},
|
||||
}),
|
||||
)])
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(thread_id) = thread_id {
|
||||
let (_, thread) = self.load_thread(&thread_id).await?;
|
||||
@@ -435,8 +451,12 @@ impl McpRequestProcessor {
|
||||
let origin_call_id =
|
||||
origin_call_id.filter(|_| server == codex_mcp::CODEX_APPS_MCP_SERVER_NAME);
|
||||
let result = match origin_call_id.as_deref() {
|
||||
Some(call_id) => thread.read_mcp_resource_for_call(call_id, &uri).await,
|
||||
None => thread.read_mcp_resource(&server, &uri).await,
|
||||
Some(call_id) => {
|
||||
thread
|
||||
.read_mcp_resource_for_call(call_id, &resource_params.uri)
|
||||
.await
|
||||
}
|
||||
None => thread.read_mcp_resource(&server, resource_params).await,
|
||||
};
|
||||
Self::send_mcp_resource_read_response(outgoing, request_id, result, origin_call_id)
|
||||
.await;
|
||||
@@ -470,7 +490,7 @@ impl McpRequestProcessor {
|
||||
codex_apps_tools_cache,
|
||||
tool_catalog_cache,
|
||||
&server,
|
||||
&uri,
|
||||
resource_params,
|
||||
)
|
||||
.await
|
||||
.and_then(|result| serde_json::to_value(result).map_err(anyhow::Error::from));
|
||||
|
||||
Reference in new issue
Block a user