fix: forward _meta field in SDK MCP tools/call requests#436
fix: forward _meta field in SDK MCP tools/call requests#436phil65 wants to merge 1 commit intoanthropics:mainfrom
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the _meta field from MCP tool call requests was not being forwarded to CallToolRequestParams, resulting in the loss of important metadata like claudecode/toolUseId when using SDK transport. This metadata is essential for MCP servers to correlate tool calls with their originating requests, particularly for progress events that need to reference the correct tool_call_id.
- Adds
_metafield forwarding toCallToolRequestParamsin the SDK MCP request handler - Uses safe dictionary access with
params.get("_meta")to handle cases where the field is not present - Aligns with the existing pattern for forwarding other fields like
nameandarguments
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| name=params.get("name"), arguments=params.get("arguments", {}) | ||
| name=params.get("name"), | ||
| arguments=params.get("arguments", {}), | ||
| _meta=params.get("_meta"), |
There was a problem hiding this comment.
The _meta field forwarding is not covered by tests. Consider adding a test case to verify that the _meta field is correctly passed through from the incoming JSONRPC message to the CallToolRequestParams. This would help ensure that metadata like claudecode/toolUseId is properly preserved when using SDK transport.
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.