You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Image/ImageContent serialization fails in stateless HTTP mode #2376
When using FastMCP with stateless_http=True (required by Claude.ai remote MCP), returning Image or ImageContent from a @mcp.tool() function results in serialization errors. Text-only tool results work fine in the same configuration.
Environment
mcp version: 1.26.0 (also tested with >=1.8.0 unpinned)
Python: 3.12
Transport: streamable-http
Deployment: Railway (remote, accessed by Claude.ai)
Attempt 1: Image class + stateless_http=True + json_response=True
Unable to serialize unknown type: <class 'mcp.server.fastmcp.utilities.types.Image'>
Attempt 2: Image class + stateless_http=True + json_response=False
Same serialization error.
Attempt 3: ImageContent from mcp.types + stateless_http=True
{"error": "Error occurred during tool execution"}
Server returns 200 OK but client receives generic error.
Attempt 4: Image class + stateless_http=False (stateful mode)
POST /mcp HTTP/1.1" 400 Bad Request
Claude.ai rejects stateful mode entirely.
Expected behavior
Image and ImageContent should serialize correctly in stateless_http=True mode, since:
The MCP spec defines ImageContent as a valid tool result content type
ToolResultContent.content accepts ContentBlock lists which include image content
The official SDK docs show @mcp.tool() returning Image as a supported pattern
The protocol's Streamable HTTP transport has no text-only restriction — it returns either application/json or text/event-stream, both capable of carrying base64-encoded image data
Context
This blocks any MCP server deployed for Claude.ai from returning images via tool results. The only workaround is returning image URLs as text, which doesn't work for authenticated/signed URLs (e.g., Notion S3 hosted images that require download proxying).
Activity
Kludex commentedon Apr 5, 2026
Seems a valid issue. We should fix this.
RudrenduPaul commentedon Apr 11, 2026
RudrenduPaul commentedon Apr 11, 2026