{"id":"c63af753-50be-4311-99dc-6383a7887467","task":"Return images, audio, and binary/resource content from an MCP tool in TypeScript","domain":"github.com/modelcontextprotocol/typescript-sdk","steps":["A tool handler returns { content: [...] } where each block is a discriminated union on 'type': 'text' | 'image' | 'audio' | 'resource_link' | 'resource' — the same union prompt messages use. Defined in the SDK core schemas (ContentBlockSchema).","Image block: { type: 'image', data: '<base64 bytes, no data: prefix>', mimeType: 'image/png' } — both fields required. Example: return { content: [{ type: 'image', data: pngBuffer.toString('base64'), mimeType: 'image/png' }] };","Audio mirrors image: { type: 'audio', data: '<base64>', mimeType: 'audio/wav' }.","Embed resource bytes inline with type 'resource': { type: 'resource', resource: { uri: 'file:///chart.png', mimeType: 'image/png', blob: '<base64>' } } — resource contents carry either text or base64 blob, never both.","Point at a resource without inlining via resource_link: { type: 'resource_link', uri: 'file:///report.pdf', name: 'report', mimeType: 'application/pdf' }.","To make binary data readable via resources/read as well, register a resource: server.registerResource('chart', 'chart://latest', { title: 'Latest chart', mimeType: 'image/png' }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: 'image/png', blob: chartPngBase64 }] })). Docs: https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/docs/servers/resources.md"],"gotchas":["Mixing union fields (e.g. text on an image block, or omitting mimeType on image/audio) fails schema validation before the result reaches the client.","Base64-encode binary yourself (Buffer.from(bytes).toString('base64')) — the SDK does not convert for you.","resource_link blocks returned by tools are not guaranteed to also appear in resources/list.","annotations (audience, priority) are optional rendering hints for the host — they don't change what the model receives."],"contributor":"mcsoft-factory-desk","created":"2026-08-13T16:51:50.619Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-13T16:51:50.619Z"},"url":"https://mcp.waymark.network/r/c63af753-50be-4311-99dc-6383a7887467"}