René's URL Explorer Experiment


Title: Image/ImageContent serialization fails in stateless HTTP mode · Issue #2376 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Image/ImageContent serialization fails in stateless HTTP mode · Issue #2376 · modelcontextprotocol/python-sdk

X Title: Image/ImageContent serialization fails in stateless HTTP mode · Issue #2376 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description Description When using...

Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...

X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2376

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Image/ImageContent serialization fails in stateless HTTP mode","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\n## Description\n\nWhen 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.\n\n## Environment\n\n- `mcp` version: 1.26.0 (also tested with `>=1.8.0` unpinned)\n- Python: 3.12\n- Transport: `streamable-http`\n- Deployment: Railway (remote, accessed by Claude.ai)\n- Client: Claude.ai (requires `stateless_http=True`)\n\n## Reproduction\n\nMinimal server:\n\n```python\nfrom mcp.server.fastmcp import FastMCP, Image\n\nmcp = FastMCP(\n    \"test\",\n    host=\"0.0.0.0\",\n    port=8000,\n    stateless_http=True,\n    json_response=True,\n)\n\n@mcp.tool()\ndef text_tool() -> str:\n    \"\"\"Works fine\"\"\"\n    return \"hello\"\n\n@mcp.tool()\ndef image_tool() -> Image:\n    \"\"\"Fails with serialization error\"\"\"\n    # 1x1 red PNG\n    data = bytes.fromhex(\n        \"89504e470d0a1a0a0000000d49484452000000010000000108020000009001\"\n        \"2e00000000c4948444154789c6260f8cf00000000020001e221bc330000000049454e44ae426082\"\n    )\n    return Image(data=data, format=\"png\")\n\nif __name__ == \"__main__\":\n    mcp.run(transport=\"streamable-http\")\n```\n\n## What happens\n\n### Attempt 1: `Image` class + `stateless_http=True` + `json_response=True`\n\n```\nUnable to serialize unknown type: \u003cclass 'mcp.server.fastmcp.utilities.types.Image'>\n```\n\n### Attempt 2: `Image` class + `stateless_http=True` + `json_response=False`\n\nSame serialization error.\n\n### Attempt 3: `ImageContent` from `mcp.types` + `stateless_http=True`\n\n```\n{\"error\": \"Error occurred during tool execution\"}\n```\n\nServer returns 200 OK but client receives generic error.\n\n### Attempt 4: `Image` class + `stateless_http=False` (stateful mode)\n\n```\nPOST /mcp HTTP/1.1\" 400 Bad Request\n```\n\nClaude.ai rejects stateful mode entirely.\n\n## Expected behavior\n\n`Image` and `ImageContent` should serialize correctly in `stateless_http=True` mode, since:\n\n1. The MCP spec defines `ImageContent` as a valid tool result content type\n2. `ToolResultContent.content` accepts `ContentBlock` lists which include image content\n3. The official SDK docs show `@mcp.tool()` returning `Image` as a supported pattern\n4. 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\n\n## Context\n\nThis 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).\n\n## Related\n\n- Python SDK Image example: https://github.com/modelcontextprotocol/python-sdk#primitives\n- MCP spec tool results: https://spec.modelcontextprotocol.io/specification/server/tools/\n\n### Example Code\n\n```Python\n\n```\n\n### Python & MCP Python SDK\n\n```Text\nMCP version: 1.26.0\nPython: 3.12\n```","author":{"url":"https://github.com/Kunyu-Chen","@type":"Person","name":"Kunyu-Chen"},"datePublished":"2026-03-29T12:32:53Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/2376"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d8db44b8-902b-c187-d135-303ce0d2e078
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB5FE:3A4875:987DB3:CC80AC:6B00E88F
html-safe-nonce6da661343565918c9df82b9ae15ba12adbace3a4f1b02b722f0d6edb0eeda18e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUZFOjNBNDg3NTo5ODdEQjM6Q0M4MEFDOjZCMDBFODhGIiwidmlzaXRvcl9pZCI6IjQ3NjIyMzU0NDcyNjQ5OTU0NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb6bacc2621d54b6c632fd22787a6dc8b060395ce3926c85f44fd45a9a2294b90
hovercard-subject-tagissue:4164092804
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/2376/issue_layout
twitter:imagehttps://opengraph.githubassets.com/88c277d3b17b767fc7afca6361a78358960bfbb0051cacb739124678cbb1531d/modelcontextprotocol/python-sdk/issues/2376
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/88c277d3b17b767fc7afca6361a78358960bfbb0051cacb739124678cbb1531d/modelcontextprotocol/python-sdk/issues/2376
og:image:altInitial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKunyu-Chen
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/2376#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2376
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2376
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2376
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2376
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2376
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues308 (308)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2376
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2376
Image/ImageContent serialization fails in stateless HTTP modehttps://github.com/modelcontextprotocol/python-sdk/issues/2376#top
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
needs confirmationNeeds confirmation that the PR is actually required or needed.https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
https://github.com/Kunyu-Chen
Kunyu-Chenhttps://github.com/Kunyu-Chen
on Mar 29, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2376#issue-4164092804
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
https://github.com/modelcontextprotocol/python-sdk#primitiveshttps://github.com/modelcontextprotocol/python-sdk#primitives
https://spec.modelcontextprotocol.io/specification/server/tools/https://spec.modelcontextprotocol.io/specification/server/tools/
https://github.com/Kludex
Kludexhttps://github.com/Kludex
on Apr 5, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2376#issuecomment-4188780588
https://github.com/RudrenduPaul
RudrenduPaulhttps://github.com/RudrenduPaul
on Apr 11, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2376#issuecomment-4228320730
https://github.com/RudrenduPaul
RudrenduPaulhttps://github.com/RudrenduPaul
on Apr 11, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2376#issuecomment-4228344650
maxisbeyhttps://github.com/maxisbey
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
needs confirmationNeeds confirmation that the PR is actually required or needed.https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
on Aug 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2376#event-29453831292
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2376
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/2376
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
needs confirmationNeeds confirmation that the PR is actually required or needed.https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.