From 07de82ba9b534db18395c72a36197825646d3eac Mon Sep 17 00:00:00 2001 From: Andrew Harvard Date: Tue, 16 Dec 2025 16:54:55 -0500 Subject: [PATCH] fix: MCP UI not rendering due to CallToolResult structure change (#6143) --- .../src/components/ToolCallWithResponse.tsx | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ui/desktop/src/components/ToolCallWithResponse.tsx b/ui/desktop/src/components/ToolCallWithResponse.tsx index e8fa950267..b3d2e56d0c 100644 --- a/ui/desktop/src/components/ToolCallWithResponse.tsx +++ b/ui/desktop/src/components/ToolCallWithResponse.tsx @@ -15,7 +15,7 @@ import { ChevronRight, FlaskConical } from 'lucide-react'; import { TooltipWrapper } from './settings/providers/subcomponents/buttons/TooltipWrapper'; import MCPUIResourceRenderer from './MCPUIResourceRenderer'; import { isUIResource } from '@mcp-ui/client'; -import { Content, EmbeddedResource } from '../api'; +import { CallToolResponse, Content, EmbeddedResource } from '../api'; interface ToolCallWithResponseProps { isCancelledMessage: boolean; @@ -26,11 +26,15 @@ interface ToolCallWithResponseProps { append?: (value: string) => void; // Function to append messages to the chat } -function getToolResultValue(toolResult: Record): Content[] | null { - if ('value' in toolResult && Array.isArray(toolResult.value)) { - return toolResult.value as Content[]; +function getToolResultContent(toolResult: Record): Content[] { + if (toolResult.status !== 'success') { + return []; } - return null; + const value = toolResult.value as CallToolResponse; + return value.content.filter((item) => { + const annotations = (item as { annotations?: { audience?: string[] } }).annotations; + return !annotations?.audience || annotations.audience.includes('user'); + }); } function isEmbeddedResource(content: Content): content is EmbeddedResource { @@ -76,7 +80,7 @@ export default function ToolCallWithResponse({ {/* MCP UI — Inline */} {toolResponse?.toolResult && - getToolResultValue(toolResponse.toolResult)?.map((content, index) => { + getToolResultContent(toolResponse.toolResult).map((content, index) => { const resourceContent = isEmbeddedResource(content) ? { ...content, type: 'resource' as const } : null; @@ -253,12 +257,9 @@ function ToolCallView({ } }, [toolResponse, startTime]); - const toolResults: Content[] = - loadingStatus === 'success' && Array.isArray(toolResponse?.toolResult.value) - ? toolResponse!.toolResult.value.filter((item) => { - const audience = item.annotations?.audience as string[] | undefined; - return !audience || audience.includes('user'); - }) + const toolResults = + loadingStatus === 'success' && toolResponse?.toolResult + ? getToolResultContent(toolResponse.toolResult) : []; const logs = notifications