Binary vs Text
Resources can return two types of content:
- Text: For code, logs, and prose.
- Blob: For images, PDFs, or binary files. These must be base64 encoded.
Encoding a Blob
typescript return { contents: [{ uri: "...", blob: Buffer.from("image_data").toString("base64"), mimeType: "image/png" }] };
Assignment: Implement a resource that returns a small base64-encoded image string.