MCPcopy
hub / github.com/codeaashu/claude-code / createContentSummary

Function createContentSummary

src/tools/BashTool/utils.ts:198–223  ·  view source on GitHub ↗
(content: ContentBlockParam[])

Source from the content-addressed store, hash-verified

196 * Used to display MCP results with images and text in the UI.
197 */
198export function createContentSummary(content: ContentBlockParam[]): string {
199 const parts: string[] = []
200 let textCount = 0
201 let imageCount = 0
202
203 for (const block of content) {
204 if (block.type === 'image') {
205 imageCount++
206 } else if (block.type === 'text' && 'text' in block) {
207 textCount++
208 // Include first 200 chars of text blocks for context
209 const preview = block.text.slice(0, 200)
210 parts.push(preview + (block.text.length > 200 ? '...' : ''))
211 }
212 }
213
214 const summary: string[] = []
215 if (imageCount > 0) {
216 summary.push(`[${imageCount} ${plural(imageCount, 'image')}]`)
217 }
218 if (textCount > 0) {
219 summary.push(`[${textCount} text ${plural(textCount, 'block')}]`)
220 }
221
222 return `MCP Result: ${summary.join(', ')}${parts.length > 0 ? '\n\n' + parts.join('\n\n') : ''}`
223}
224

Callers

nothing calls this directly

Calls 2

pluralFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected