From 74f73b073c53d8012183aec7ce9a30fe1b30fc96 Mon Sep 17 00:00:00 2001 From: Philipp Temminghoff Date: Mon, 22 Dec 2025 23:49:21 +0100 Subject: [PATCH] fix: forward _meta field in SDK MCP tools/call requests The _meta field from MCP tool call requests was not being forwarded to CallToolRequestParams, causing metadata like claudecode/toolUseId to be lost when using SDK transport. This metadata is needed by MCP servers to correlate tool calls with their originating requests (e.g., for progress events that need to reference the correct tool_call_id). The fix simply passes params.get('_meta') to CallToolRequestParams, which already supports this field via its RequestParams base class. --- src/claude_agent_sdk/_internal/query.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/claude_agent_sdk/_internal/query.py b/src/claude_agent_sdk/_internal/query.py index c30fc159..627b6ee8 100644 --- a/src/claude_agent_sdk/_internal/query.py +++ b/src/claude_agent_sdk/_internal/query.py @@ -467,7 +467,9 @@ async def _handle_sdk_mcp_request( call_request = CallToolRequest( method=method, params=CallToolRequestParams( - name=params.get("name"), arguments=params.get("arguments", {}) + name=params.get("name"), + arguments=params.get("arguments", {}), + _meta=params.get("_meta"), ), ) handler = server.request_handlers.get(CallToolRequest)