Forward caller metadata on MCP resource reads (#59509)

## What changed

Accept an optional `_meta` object on `mcpServer/resource/read` and forward it to MCP `resources/read`, including reads bound to an originating tool call. Update the protocol schemas and generated TypeScript and Python types.

Reject caller metadata containing host-owned `threadId`, `x-codex-turn-metadata`, or `codex/connectionLease` keys. For `codex_apps`, also reserve `connector_id`, `link_id`, and `_codex_apps.resource_uri` to preserve app and account routing.

## Testing

Add integration coverage for metadata forwarding through stdio, hosted app reads with and without a thread, and origin-bound widget reads. Cover rejection of reserved keys and non-object metadata.

GitOrigin-RevId: 227ee0fb5fe15fa2ff2ec66d4d5ae16de8935a8c
This commit is contained in:
Joe Savona
2026-11-04 22:55:22 +00:00
committed by copyberry
parent ad5e6e57a1
commit aa1399cbcd
22 changed files with 279 additions and 40 deletions
+2 -2
View File
@@ -1380,14 +1380,14 @@ impl CodexThread {
pub async fn read_mcp_resource_for_call(
&self,
call_id: &str,
uri: &str,
params: ReadResourceRequestParams,
) -> anyhow::Result<serde_json::Value> {
self.session.refresh_mcp_if_dirty().await;
let result = self
.session
.services
.mcp_runtime
.read_resource_for_call(self.session.thread_id, call_id, uri)
.read_resource_for_call(self.session.thread_id, call_id, params)
.await?;
Ok(serde_json::to_value(result)?)