MCPcopy Index your code
hub / github.com/codeaashu/claude-code / renderToolResultMessage

Function renderToolResultMessage

src/tools/MCPTool/UI.tsx:91–150  ·  view source on GitHub ↗
(output: string | MCPToolResult, _progressMessagesForMessage: ProgressMessage<ToolProgressData>[], {
  verbose,
  input
}: {
  verbose: boolean;
  input?: unknown;
})

Source from the content-addressed store, hash-verified

89 </MessageResponse>;
90}
91export function renderToolResultMessage(output: string | MCPToolResult, _progressMessagesForMessage: ProgressMessage<ToolProgressData>[], {
92 verbose,
93 input
94}: {
95 verbose: boolean;
96 input?: unknown;
97}): React.ReactNode {
98 const mcpOutput = output as MCPToolResult;
99 if (!verbose) {
100 const slackSend = trySlackSendCompact(mcpOutput, input);
101 if (slackSend !== null) {
102 return <MessageResponse height={1}>
103 <Text>
104 Sent a message to{' '}
105 <Ansi>{createHyperlink(slackSend.url, slackSend.channel)}</Ansi>
106 </Text>
107 </MessageResponse>;
108 }
109 }
110 const estimatedTokens = getContentSizeEstimate(mcpOutput);
111 const showWarning = estimatedTokens > MCP_OUTPUT_WARNING_THRESHOLD_TOKENS;
112 const warningMessage = showWarning ? `${figures.warning} Large MCP response (~${formatNumber(estimatedTokens)} tokens), this can fill up context quickly` : null;
113 let contentElement: React.ReactNode;
114 if (Array.isArray(mcpOutput)) {
115 const contentBlocks = mcpOutput.map((item, i) => {
116 if (item.type === 'image') {
117 return <Box key={i} justifyContent="space-between" overflowX="hidden" width="100%">
118 <MessageResponse height={1}>
119 <Text>[Image]</Text>
120 </MessageResponse>
121 </Box>;
122 }
123 // For text blocks and any other block types, extract text if available
124 const textContent = item.type === 'text' && 'text' in item && item.text !== null && item.text !== undefined ? String(item.text) : '';
125 return feature('MCP_RICH_OUTPUT') ? <MCPTextOutput key={i} content={textContent} verbose={verbose} /> : <OutputLine key={i} content={textContent} verbose={verbose} />;
126 });
127
128 // Wrap array content in a column layout
129 contentElement = <Box flexDirection="column" width="100%">
130 {contentBlocks}
131 </Box>;
132 } else if (!mcpOutput) {
133 contentElement = <Box justifyContent="space-between" overflowX="hidden" width="100%">
134 <MessageResponse height={1}>
135 <Text dimColor>(No content)</Text>
136 </MessageResponse>
137 </Box>;
138 } else {
139 contentElement = feature('MCP_RICH_OUTPUT') ? <MCPTextOutput content={mcpOutput} verbose={verbose} /> : <OutputLine content={mcpOutput} verbose={verbose} />;
140 }
141 if (warningMessage) {
142 return <Box flexDirection="column">
143 <MessageResponse height={1}>
144 <Text color="warning">{warningMessage}</Text>
145 </MessageResponse>
146 {contentElement}
147 </Box>;
148 }

Callers

nothing calls this directly

Calls 5

trySlackSendCompactFunction · 0.85
createHyperlinkFunction · 0.85
getContentSizeEstimateFunction · 0.85
formatNumberFunction · 0.85
featureFunction · 0.85

Tested by

no test coverage detected