feat(claude-agent-sdk): surface raw MCP tool name via metadata - #2638
Open
boyuan-fh wants to merge 1 commit into
Open
feat(claude-agent-sdk): surface raw MCP tool name via metadata#2638boyuan-fh wants to merge 1 commit into
boyuan-fh wants to merge 1 commit into
Conversation
stripMcpPrefix makes a built-in Bash call and an mcp__server__Bash call byte-identical in the event stream and message history. Carry the original prefixed name in the existing metadata map (metadata.rawName) on both TOOL_CALL_START events and assistant-message tool calls, keeping toolCallName/function.name as the stripped display name. No @ag-ui/core schema change. Fixes #<issue>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2633
Problem
stripMcpPrefixremoves themcp__<server>__prefix from tool names beforethe adapter emits
TOOL_CALL_STARTevents and before it builds assistantmessage tool calls. This makes built-in and MCP tool calls indistinguishable
in the event stream and message history.
Changes (integration package only -- no
@ag-ui/corechange)metadata: { rawName }onTOOL_CALL_STARTin both the streaming path(
adapter.ts) and the non-streaming path (handlers.ts), carrying the rawprefixed name while
toolCallNamestays the stripped display name.metadata: { rawName }on tool calls built bybuildAguiAssistantMessage(
utils.ts) and on the in-flight message accumulator (adapter.ts).metadata.rawNameequals the display name.The raw name uses the
metadatamap that bothBaseEventSchema(events) andToolCallSchema(messages) already declare, so no shared-schema edit isrequired and the field survives
.parse()on both surfaces.Tests (new
adapter.raw-tool-name.test.ts+schema-survival.test.ts)metadata.rawNamewith the full prefix on the streaming path;built-in tool emits
metadata.rawNameequal to the display name.metadata.rawName.MESSAGES_SNAPSHOTcarrymetadata.rawName.schema-survival.test.tsparses through the realToolCallStartEventSchemaand
ToolCallSchemafrom@ag-ui/coreand assertsmetadata.rawNamesurvives
.parse()on both -- proving the design premise against the realschemas rather than a mock.