René's URL Explorer Experiment


Title: Tool return annotations for `Enum`/`UUID`/`datetime`/`Decimal`/`Path` drop structured output, and `AnyUrl`/`AnyHttpUrl` silently emit `{}` · Issue #3886 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Tool return annotations for `Enum`/`UUID`/`datetime`/`Decimal`/`Path` drop structured output, and `AnyUrl`/`AnyHttpUrl` silently emit `{}` · Issue #3886 · modelcontextprotocol/python-sdk

X Title: Tool return annotations for `Enum`/`UUID`/`datetime`/`Decimal`/`Path` drop structured output, and `AnyUrl`/`AnyHttpUrl` silently emit `{}` · Issue #3886 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before openi...

Open Graph Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontex...

X Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/mod...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tool return annotations for `Enum`/`UUID`/`datetime`/`Decimal`/`Path` drop structured output, and `AnyUrl`/`AnyHttpUrl` silently emit `{}`","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Release line\n\n2.x (current stable)\n\n### Description\n\nIn `src/mcp/server/mcpserver/utilities/func_metadata.py`, `_create_output_model()` only sends exact builtin types `(str, int, float, bool, bytes, type(None), list, tuple, set, frozenset)` to the `{\"result\": ...}` wrapper (Case 4), and falls through to Case 5 (`type_hints = get_type_hints(type_annotation)`) for every other non-`BaseModel`, non-`TypedDict`, non-`dict` class.\n\nThis causes two concrete bugs for standard Pydantic-serializable return annotations:\n\n1. **Silent data loss for `AnyUrl` / `AnyHttpUrl` (and other non-`BaseModel` Pydantic scalar types with private annotations)**:\n   - `get_type_hints(AnyHttpUrl)` is non-empty (it contains private attributes such as `_constraints`), which `_create_model_from_class()` skips (`if field_name.startswith(\"_\"): continue`).\n   - As a result, `_create_model_from_class()` builds an **empty `BaseModel` with zero fields**:\n     `output_schema == {'properties': {}, 'title': 'AnyHttpUrl', 'type': 'object'}`.\n   - When the tool runs, `convert_result()` silently discards the URL and returns **`structured_content == {}`**!\n\n2. **Dropped structured output / `InvalidSignature` for standard library enums and value types**:\n   - `Enum` / `StrEnum` / `IntEnum`, `UUID`, `datetime`, `date`, `time`, `timedelta`, `Decimal`, `Path` / `PurePath`, and `IPv4Address` / `IPv6Address` / `IPv4Interface` / `IPv6Interface` / `IPv4Network` / `IPv6Network` all have empty `get_type_hints(...)`, so `_create_output_model()` returns `(None, False)`.\n   - With default `structured_output=None`, `output_schema` is silently `None` and no `structured_content` is emitted.\n   - With `structured_output=True`, registration raises `InvalidSignature: return type ... is not serializable for structured output`—even though Pydantic natively serializes all of these types, they work as tool input parameters, and wrapped/generic forms like `-> list[Color]` or `-> Color | None` already work cleanly.\n\n#### Expected behavior\n\nFollowing the same principle as #3758 (bare `dict`/`set`/`frozenset`), standard Pydantic-serializable scalar/enum types (`Enum`, `date`/`datetime`/`time`/`timedelta`, `Decimal`, `UUID`, `PurePath`, `ipaddress` types) and non-`BaseModel` types implementing `__get_pydantic_core_schema__` (such as `AnyUrl` / `AnyHttpUrl`) should be wrapped in `{\"result\": ...}` in Case 4 of `_create_output_model()`, producing a valid object `output_schema` and preserving the serialized value under `structured_content[\"result\"]`.\n\nUnannotated custom classes (`class Foo: ...`) and `NamedTuple` subclasses remain unaffected.\n\nI have a minimal fix + 13 parametrized regression tests verified locally (`pytest`, `ruff`, `pyright`) and would be happy to submit a PR if this is confirmed.\n\n### Example Code\n\n```python\nfrom datetime import datetime\nfrom decimal import Decimal\nfrom enum import StrEnum\nfrom pathlib import Path\nfrom uuid import UUID\n\nfrom pydantic import AnyHttpUrl\n\nfrom mcp.server.mcpserver import MCPServer\nfrom mcp.server.mcpserver.utilities.func_metadata import func_metadata\n\n\nclass Color(StrEnum):\n    RED = \"red\"\n    BLUE = \"blue\"\n\n\ndef get_homepage() -> AnyHttpUrl:\n    return AnyHttpUrl(\"https://example.com\")\n\n\nmeta = func_metadata(get_homepage)\nprint(\"AnyHttpUrl output_schema:\", meta.output_schema)\nprint(\"AnyHttpUrl structured_content:\", meta.convert_result(get_homepage()).structured_content)\n# Actual:\n# AnyHttpUrl output_schema: {'properties': {}, 'title': 'AnyHttpUrl', 'type': 'object'}\n# AnyHttpUrl structured_content: {}  \u003c-- URL silently lost!\n\n\ndef get_color() -> Color:\n    return Color.RED\n\n\nprint(\"Color (default) output_schema:\", func_metadata(get_color).output_schema)\n# Actual: None\n\nmcp = MCPServer(\"repro\")\nfor ret_type in (Color, UUID, datetime, Decimal, Path):\n    def fn():\n        return None\n    fn.__annotations__ = {\"return\": ret_type}\n    try:\n        mcp.add_tool(fn, name=f\"t_{ret_type.__name__}\", structured_output=True)\n    except Exception as e:\n        print(f\"{ret_type.__name__} (structured_output=True) -> {type(e).__name__}: {e}\")\n# Actual:\n# Color (structured_output=True) -> InvalidSignature: Function fn: return type \u003cenum 'Color'> is not serializable for structured output\n# UUID (structured_output=True) -> InvalidSignature: Function fn: return type \u003cclass 'uuid.UUID'> is not serializable for structured output\n# datetime (structured_output=True) -> InvalidSignature: Function fn: return type \u003cclass 'datetime.datetime'> is not serializable for structured output\n# Decimal (structured_output=True) -> InvalidSignature: Function fn: return type \u003cclass 'decimal.Decimal'> is not serializable for structured output\n# Path (structured_output=True) -> InvalidSignature: Function fn: return type \u003cclass 'pathlib.Path'> is not serializable for structured output\n```\n\n### Python & MCP Python SDK\n\n```text\nPython 3.14.8, macOS\nmodelcontextprotocol/python-sdk main @ 77001c96 (2.3.1.dev20+77001c96)\n```\n\n---\n*AI disclosure: AI assistance was used to help investigate and draft this issue; the reproduction and observed output were verified locally.*\n","author":{"url":"https://github.com/0718lol","@type":"Person","name":"0718lol"},"datePublished":"2026-11-21T05:35:35Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3886"}

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:01504f30-4028-fb3e-ed18-caab318d6001
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD772:2DE1B0:4C97C3:6ABB9C:6B05BB4D
html-safe-nonce6f26931004eb182fcb4748f9e5bd49fc0f9d4149798ca8d74f5f4654152879d4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzcyOjJERTFCMDo0Qzk3QzM6NkFCQjlDOjZCMDVCQjREIiwidmlzaXRvcl9pZCI6IjI0NjI4NzEwOTEyNzQ5NTU1OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9faaac9e54291a914ab7d4db140efe572593499f4198c2ce9c6007fdb97ccc91
hovercard-subject-tagissue:6525003801
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/3886/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4cc7462e286a1700128a5d26181e6a923f40dd11ebbdfc972d5a7eb76b861454/modelcontextprotocol/python-sdk/issues/3886
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4cc7462e286a1700128a5d26181e6a923f40dd11ebbdfc972d5a7eb76b861454/modelcontextprotocol/python-sdk/issues/3886
og:image:altInitial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontex...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:username0718lol
hostnamegithub.com
expected-hostnamegithub.com
None708c2f10d746dbcf1dd80dc8309daa7d595df3fce8066244380fc3238618f09c
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
release2a29e3cf4fb57e81fd311774f91f345cc4436f40
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3886#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3886
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%2F3886
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/3886
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3886
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3886
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues320 (320)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/3886
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3886
Tool return annotations for Enum/UUID/datetime/Decimal/Path drop structured output, and AnyUrl/AnyHttpUrl silently emit {}https://github.com/modelcontextprotocol/python-sdk/issues/3886#top
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/0718lol
0718lolhttps://github.com/0718lol
on Nov 21, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3886#issue-6525003801
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
#3758https://github.com/modelcontextprotocol/python-sdk/pull/3758
claudehttps://github.com/apps/claude
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
on Nov 21, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3886#event-36840666294
https://github.com/Shanmukh-l33t
Shanmukh-l33thttps://github.com/Shanmukh-l33t
on Nov 21, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3886#issuecomment-7065869890
77001c9https://github.com/modelcontextprotocol/python-sdk/commit/77001c96f9507be0f4d009b83210a384a5e08bda
main...Shanmukh-l33t:python-sdk:fix/tool-return-scalar-structured-outputhttps://github.com/modelcontextprotocol/python-sdk/compare/main...Shanmukh-l33t:python-sdk:fix/tool-return-scalar-structured-output
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3886
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3886
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.