小橙子 2c897d2c82
fix(image-gen): use standard MCP image block instead of custom image_url type (#67)
The MCP content schema only allows text/image/audio/resource/resource_link.
PR#63 introduced a custom {type: "image_url"} block that passes Desktop's
extractImageBlocks() parsing but is rejected by the MCP SDK's schema
validation before it ever reaches the client, causing a "Invalid input"
error on every successful image generation.

Additionally, using base64 image blocks causes conversation history to
accumulate MB-scale data per image. After 3-4 generations the request
exceeds the 20MB API limit ("Request too large").

Fix (two-part):
1. MCP server: for URL-type results, return a standard text block with
   markdown image syntax ![generated-image](url). No base64, no custom
   types — passes schema validation and keeps conversation history lean.
   Includes _meta.imageUrls for future extensibility.

2. Desktop extractImageBlocks: now also extracts image URLs from
   markdown syntax (![...](https://...)) in text blocks, enabling
   inline rendering of URL-based images from tool results.

This approach avoids the 20MB accumulation problem entirely — image URLs
are just a few bytes of text in the conversation history, while Desktop
still renders them inline.

Co-authored-by: 你的姓名 <you@example.com>
2026-06-17 05:20:12 +08:00
..