Title: PydanticSchemaGenerationError: Unable to generate pydantic-core schema for Image type · Issue #1060 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: PydanticSchemaGenerationError: Unable to generate pydantic-core schema for Image type · Issue #1060 · modelcontextprotocol/python-sdk
X Title: PydanticSchemaGenerationError: Unable to generate pydantic-core schema for Image type · Issue #1060 · 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 The Image type in ques...
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/1060
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PydanticSchemaGenerationError: Unable to generate pydantic-core schema for Image type","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\nThe `Image` type in question is imported like this: `from mcp.server.fastmcp.utilities.types import Image`\n\nWe are upgrading our dependency on `mcp` from 1.9.4 to 1.10.1.\n\nOnce on 1.10.1 our application and tests began to fail with error like this:\n```\npydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema\nfor \u003cclass 'mcp.server.fastmcp.utilities.types.Image'>. Set `arbitrary_types_allowed=True` in\nthe model_config to ignore this error or implement `__get_pydantic_core_schema__` on your\ntype to fully support it.\n```\n\nI found a test tool function among this repo's unit tests, that is pretty close to the mixed content\nuse case in our server. So I tweaked it to create a repro case for you:\n\n```diff\ndiff --git a/tests/server/fastmcp/test_server.py b/tests/server/fastmcp/test_server.py\nindex c30930f..20c25af 100644\n--- a/tests/server/fastmcp/test_server.py\n+++ b/tests/server/fastmcp/test_server.py\n@@ -194,12 +194,12 @@ def image_tool_fn(path: str) -> Image:\n return Image(path)\n \n \n-def mixed_content_tool_fn() -> list[ContentBlock]:\n- return [\n- TextContent(type=\"text\", text=\"Hello\"),\n- ImageContent(type=\"image\", data=\"abc\", mimeType=\"image/png\"),\n+def mixed_content_tool_fn() -> tuple[str, Image, AudioContent]:\n+ return (\n+ \"Hello\",\n+ Image(data=b\"abc\", format=\"png\"),\n AudioContent(type=\"audio\", data=\"def\", mimeType=\"audio/wav\"),\n- ]\n+ )\n \n \n class TestServerTools:\n@@ -311,7 +311,7 @@ class TestServerTools:\n assert content1.text == \"Hello\"\n assert isinstance(content2, ImageContent)\n assert content2.mimeType == \"image/png\"\n- assert content2.data == \"abc\"\n+ assert content2.data == \"YWJj\"\n assert isinstance(content3, AudioContent)\n assert content3.mimeType == \"audio/wav\"\n assert content3.data == \"def\"\n```\n\n`test_tool_mixed_content` fails with `PydanticSchemaGenerationError` on 1.10.1 but succeeds on 1.9.4.\n\n### Python & MCP Python SDK\n\n```Text\nPython 3.12, mcp 1.10.1\n```","author":{"url":"https://github.com/paxan","@type":"Person","name":"paxan"},"datePublished":"2025-06-30T18:40:50Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/1060"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3143ecf5-73cf-f077-e8da-845d695aad1f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E332:23AE4E:205E9CD:2ADD30F:6B0575C3 |
| html-safe-nonce | bece560bd44de12a2868bfff3724fbc2ec8d4cac6026cd070b287ba61fd1047b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzMyOjIzQUU0RToyMDVFOUNEOjJBREQzMEY6NkIwNTc1QzMiLCJ2aXNpdG9yX2lkIjoiNzM5OTk2MTk5NTQ2Mzk4MDQ4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5ff3d26efb05f7d55373fef07ad81e54d54cbbfd09b11b0f9e2a41080dc2db53 |
| hovercard-subject-tag | issue:3189494707 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/1060/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9ec044cee282361942129aafea2ccca89462281014b494b86792c4ff966cc4c3/modelcontextprotocol/python-sdk/issues/1060 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9ec044cee282361942129aafea2ccca89462281014b494b86792c4ff966cc4c3/modelcontextprotocol/python-sdk/issues/1060 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | paxan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 507b2d62524c0f595c35a2a2ee8a6ec54b119f245b3c59eaa070013b70ed1ada |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e7a883ae3b439b8952652eaa7803e2587f30e339 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width