Include originating item IDs in MCP request metadata (#40866)

## What changed

- Add the originating Responses item ID to MCP tool request metadata as
  `_meta.itemId`.
- Preserve the initiating `exec` item ID across code-mode cells so nested MCP
  calls carry the same origin.

## Testing

- Cover metadata generation for direct and code-mode MCP tool calls.

GitOrigin-RevId: 1161cac64f1cc3a6d4dac4368e63804bd9d2c417
This commit is contained in:
jif authored and copyberry committed 2026-08-26 10:39:05 +00:00
1 parent 74772623db
commit f5420174da
9 files changed
+175 -49

No files matched your search

+2
View File
@@ -171,6 +171,7 @@ impl McpHandler {
&self,
invocation: ToolInvocation,
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
let originating_item_id = invocation.originating_item_id().await;
let ToolInvocation {
session,
step_context,
@@ -197,6 +198,7 @@ impl McpHandler {
&step_context,
&cancellation_token,
call_id.clone(),
originating_item_id,
&self.tool_info,
self.hook_tool_name(),
tool_name,