Title: fix: alias-normalize CallToolResult structuredContent after validate by coder058 · Pull Request #3468 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix: alias-normalize CallToolResult structuredContent after validate by coder058 · Pull Request #3468 · modelcontextprotocol/python-sdk
X Title: fix: alias-normalize CallToolResult structuredContent after validate by coder058 · Pull Request #3468 · modelcontextprotocol/python-sdk
Description: Fixes #3467 Summary FuncMetadata.convert_result validates CallToolResult.structured_content but returns the result unchanged. Plain model returns validate then model_dump/dump_python with by_alias=True, so wire keys match outputSchema. The CallToolResult path skipped that dump, so Python field names that pass validation (populate_by_name / by_name) could be emitted while outputSchema advertises aliases. Motivation and Context Clients validating structuredContent against the published outputSchema reject otherwise-valid tool results when aliases are used. This aligns the CallToolResult short-circuit with the plain-return path (#1073 / #1099). Distinct from #3100 / #3118 (schema generation mode). How Has This Been Tested? Added test_call_tool_result_structured_content_alias_normalized py -3.12 -m pytest tests/server/mcpserver/test_func_metadata.py — 59 passed Standalone repro from #3467: CallToolResult path now emits {"first":...} instead of {"field_first":...} Breaking Changes None intended. Wire output for CallToolResult tools that previously leaked Python field names will now use aliases (matching schema / plain returns). Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer) I have disclosed any AI assistance and can explain the change in my own words I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context Smallest fix: after validate_python(..., by_alias=True, by_name=True) on CallToolResult.structured_content, dump with by_alias=True and model_copy the normalized dict — same serialization as the plain-return path. AI disclosure This PR was prepared with AI assistance (Cursor / Grok): issue draft, repro, patch, and PR text. Changes were verified locally on current main (08a3bc8) with the new regression test and the full test_func_metadata.py file.
Open Graph Description: Fixes #3467 Summary FuncMetadata.convert_result validates CallToolResult.structured_content but returns the result unchanged. Plain model returns validate then model_dump/dump_python with by_alias=...
X Description: Fixes #3467 Summary FuncMetadata.convert_result validates CallToolResult.structured_content but returns the result unchanged. Plain model returns validate then model_dump/dump_python with by_alias=...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3468
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:31cbd357-9a55-bd12-f0ab-71afb2971d25 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BA2E:3DD488:823D3A:A6A343:6B00E925 |
| html-safe-nonce | 70df14ba65310dab40c349977ae8d3183ad8666b61c5b97f7e00b9d246106759 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTJFOjNERDQ4ODo4MjNEM0E6QTZBMzQzOjZCMDBFOTI1IiwidmlzaXRvcl9pZCI6IjU1MDExNzkwNDcyMTM4NTI5NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b655e12d7fbc43004230913adc41b3571714f6ef6799ba36e8f3a9e92fd3ed54 |
| hovercard-subject-tag | pull_request:4464272078 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/modelcontextprotocol/python-sdk/pull/3468/files |
| twitter:image | https://avatars.githubusercontent.com/u/139084433?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/139084433?s=400&v=4 |
| og:image:alt | Fixes #3467 Summary FuncMetadata.convert_result validates CallToolResult.structured_content but returns the result unchanged. Plain model returns validate then model_dump/dump_python with by_alias=... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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 |
Links:
Viewport: width=device-width