Title: fix(shared): strip envelope fields when forwarding JSONRPCRequest by charles-adedotun · Pull Request #2573 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix(shared): strip envelope fields when forwarding JSONRPCRequest by charles-adedotun · Pull Request #2573 · modelcontextprotocol/python-sdk
X Title: fix(shared): strip envelope fields when forwarding JSONRPCRequest by charles-adedotun · Pull Request #2573 · modelcontextprotocol/python-sdk
Description: Summary Fixes #2548. BaseSession.send_request builds the outgoing wire object as: JSONRPCRequest(jsonrpc="2.0", id=request_id, **request_data) When request_data originates from model_dump() on an existing JSONRPCRequest (a typical forwarding/proxy scenario — e.g. a ServerSession receiving an incoming request and re-emitting it via a ClientSession), the dump preserves the envelope fields jsonrpc and id, which collide with the explicit kwargs above: TypeError: got multiple values for keyword argument 'jsonrpc' Approach Conservative: pop jsonrpc and id from request_data before unpacking. This keeps the wire-envelope construction authoritative at this call site and doesn't change any model-layer dump behavior (which would have wider blast radius). As mentioned in the issue thread, I'm happy to take the model-layer approach instead (e.g. excluding envelope fields from model_dump on forwarded requests) if the maintainers prefer that — let me know. Test Added test_send_request_strips_envelope_fields_when_forwarding in tests/shared/test_session.py that reproduces the bug (test fails without the fix, passes with it) and verifies clean forwarding end-to-end with a mock server. Checklist Tests added that fail without the fix Full tests/shared/test_session.py suite passes (9/9) Full tests/ suite passes (1173 passed, 98 skipped, 1 xfailed) ruff format / ruff check clean pyright clean (0 errors, 0 warnings) No changes to public API
Open Graph Description: Summary Fixes #2548. BaseSession.send_request builds the outgoing wire object as: JSONRPCRequest(jsonrpc="2.0", id=request_id, **request_data) When request_data originates from model_dump...
X Description: Summary Fixes #2548. BaseSession.send_request builds the outgoing wire object as: JSONRPCRequest(jsonrpc="2.0", id=request_id, **request_data) When request_data originates from mo...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2573
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:dedb3e77-5c2d-9c31-841c-7d2ed5ba763f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | ADF8:9B177:1197981:193ACA7:6A5A1863 |
| html-safe-nonce | 937ac1a59f252c0e521eff3726eef3f81b94347527969d1e2cc9bb6aceed31f4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREY4OjlCMTc3OjExOTc5ODE6MTkzQUNBNzo2QTVBMTg2MyIsInZpc2l0b3JfaWQiOiI4MTk4MDczMjQwOTY0OTYyNDAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 042ad7028ecbd40c6ef6759fe9f0e1879bc418c21e6688580c573b7628c59a77 |
| hovercard-subject-tag | pull_request:3660146371 |
| 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/2573/files |
| twitter:image | https://avatars.githubusercontent.com/u/70953257?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/70953257?s=400&v=4 |
| og:image:alt | Summary Fixes #2548. BaseSession.send_request builds the outgoing wire object as: JSONRPCRequest(jsonrpc="2.0", id=request_id, **request_data) When request_data originates from model_dump... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e31742e80bbd077fd5679c13ed870ce4e0c13803a2fa5beaae557b6769de2c8a |
| 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 | c9fcdbf98c619d1561ed843fa01d9766a32b5cd9 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width