Title: fix(server): normalize experimental capability to {} in get_capabilities by Hamjaster · Pull Request #3255 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix(server): normalize experimental capability to {} in get_capabilities by Hamjaster · Pull Request #3255 · modelcontextprotocol/python-sdk
X Title: fix(server): normalize experimental capability to {} in get_capabilities by Hamjaster · Pull Request #3255 · modelcontextprotocol/python-sdk
Description: Fixes #3254 What's broken An unconfigured Server reports its experimental capability differently depending on which discovery path answers: initialize (via create_initialization_options()): experimental == {}, field present on the wire. server/discover (calls get_capabilities() directly): experimental is None, field omitted from the wire dump. That's client-visible: .get(...) works on the legacy value and raises on the modern one, and is not None checks flip meaning depending on which path answered. Same server, same lack of configuration, two different answers. Why create_initialization_options() was the only caller that normalized a missing experimental_capabilities argument to {} before handing it to get_capabilities(). get_capabilities() itself just used its own parameter default (None) whenever a caller didn't do that normalization first — and server/discover's internal handler calls get_capabilities(protocol_version=ctx.protocol_version) with nothing for experimental_capabilities, so it fell straight through to None. The fix One line: move the normalization into get_capabilities() itself, right next to the existing notification_options = notification_options or NotificationOptions() fallback that already does the same job for a sibling parameter. Now every caller gets {} unless it explicitly passes something else, regardless of which path calls it. How I checked it Ran the exact repro from the issue against both trees: # main legacy {} True modern None False # this branch legacy {} True modern {} True Added a test in tests/server/lowlevel/test_server_discover.py (the file that already exercises get_capabilities() via the discover path) asserting both create_initialization_options() and server/discover report experimental == {} for the same unconfigured server. It fails on main with assert None == {} and passes with this change. ruff format/ruff check/pyright are all clean. Ran the full tests/server/ suite (1213 tests) and it passes. I didn't run the complete coverage/strict-no-cover gate across the whole repo, but confirmed the new line is exercised (not in coverage report's missing-lines list) when running the affected test files. Type 🐛 Bug Fix Disclosure An AI coding agent helped me write this. I read the SDK's fallback pattern in get_capabilities(), picked the one-line fix that matches it, reproduced the issue's exact repro on both trees myself, and can walk through any part of this change.
Open Graph Description: Fixes #3254 What's broken An unconfigured Server reports its experimental capability differently depending on which discovery path answers: initialize (via create_initialization_options()): ex...
X Description: Fixes #3254 What's broken An unconfigured Server reports its experimental capability differently depending on which discovery path answers: initialize (via create_initialization_options())...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3255
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:ff81624c-e3ff-138f-0c8f-e6efb2262f1c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9B84:E9D16:A26DB1:CDAE24:6B0129AF |
| html-safe-nonce | 54a0dc6400664433b83ca2d04a8764c7d5f117e60d1130b9fd3006bce5709e2a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Qjg0OkU5RDE2OkEyNkRCMTpDREFFMjQ6NkIwMTI5QUYiLCJ2aXNpdG9yX2lkIjoiOTI2Njc0Mzc1OTg0MzU5ODU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a8756ff2111c51a2b6828f853461ed843669fe7c950f042d9e2fd20f145e1cd7 |
| hovercard-subject-tag | pull_request:4210323043 |
| 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/3255/files |
| twitter:image | https://avatars.githubusercontent.com/u/87142882?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/87142882?s=400&v=4 |
| og:image:alt | Fixes #3254 What's broken An unconfigured Server reports its experimental capability differently depending on which discovery path answers: initialize (via create_initialization_options()): ex... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width