How to let MCP tool return Image?

The new Attributes Support for MCP Servers is awesome. I have a question, how to let MCP tool returns an image (JPEG or PNG)?

This depends on how your client expects to deal with the image. Two obvious choices:

  1. Base64 encoded string payload (for small images)
  2. Image URI (for large images or if your client expects the image this way)