| 196 | * Used to display MCP results with images and text in the UI. |
| 197 | */ |
| 198 | export 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 | |