Title: dict[str, T] tool return types lose Annotated/Field metadata in output schema · Issue #2935 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: dict[str, T] tool return types lose Annotated/Field metadata in output schema · Issue #2935 · modelcontextprotocol/python-sdk
X Title: dict[str, T] tool return types lose Annotated/Field metadata in output schema · Issue #2935 · 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 Tools that return a st...
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/2935
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dict[str, T] tool return types lose Annotated/Field metadata in output schema","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\nTools that return a string-keyed dict (dict[str, T]) lose any Annotated/Field metadata on the return type when the output schema is generated. A Field(description=...) on the return annotation shows up in the output schema for every other return type, but for dict[str, T] it's dropped.\n\nI'd expect the description to be preserved, the same as other return types. Looks like the dict[str, T] branch in _try_create_model_and_schema builds the model from the Annotated-stripped type instead of the original annotation (there's an existing TODO on that line).\n\nHave a simple, tested fix ready to go. Love the project and would love to contribute if possible! \n\n### Example Code\n\n```Python\nfrom typing import Annotated\nfrom pydantic import Field\nfrom mcp.server.mcpserver.utilities.func_metadata import func_metadata\n\ndef get_config() -> Annotated[dict[str, int], Field(description=\"Configuration values\")]:\n return {\"timeout\": 30}\n\nprint(func_metadata(get_config).output_schema)\n# {'type': 'object', 'additionalProperties': {'type': 'integer'}, 'title': 'get_configDictOutput'}\n# expected to also include: 'description': 'Configuration values'\n```\n\n### Python & MCP Python SDK\n\n```Text\nPython 3.14.5\nmcp: main branch (mcpserver / V2)\n```","author":{"url":"https://github.com/zlucas03","@type":"Person","name":"zlucas03"},"datePublished":"2026-06-20T20:39:43Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/2935"}
| 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:9f586205-0e93-b6a0-1702-8c9aa844a9c2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2CE:37820D:B60868:F45389:6B00E6DA |
| html-safe-nonce | 5867c8f28e1ee5b3e864f97734b66a4fbaa9697613096300a8bed9188ca66331 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkNFOjM3ODIwRDpCNjA4Njg6RjQ1Mzg5OjZCMDBFNkRBIiwidmlzaXRvcl9pZCI6IjE3NDQ5ODEwOTg4ODgyMjY1MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 20e0880b58c991a159503ed58b0fd590434c2162b028a872e07a7b0158b00f78 |
| hovercard-subject-tag | issue:4708299002 |
| 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/2935/issue_layout |
| twitter:image | https://opengraph.githubassets.com/07dd8823ba04eb7259ac5fa7870c96295a3159936976d7dc4d4f4c0e855b460c/modelcontextprotocol/python-sdk/issues/2935 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/07dd8823ba04eb7259ac5fa7870c96295a3159936976d7dc4d4f4c0e855b460c/modelcontextprotocol/python-sdk/issues/2935 |
| 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 | zlucas03 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width