Title: Refactor handler context to be transport- and handler-type-aware · Issue #2021 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Refactor handler context to be transport- and handler-type-aware · Issue #2021 · modelcontextprotocol/python-sdk
X Title: Refactor handler context to be transport- and handler-type-aware · Issue #2021 · modelcontextprotocol/python-sdk
Description: The current RequestContext / ServerRequestContext design has a few rough edges that warrant a dedicated refactor: Request vs notification context — Request handlers have request_id and meta, notification handlers do not. Currently reques...
Open Graph Description: The current RequestContext / ServerRequestContext design has a few rough edges that warrant a dedicated refactor: Request vs notification context — Request handlers have request_id and meta, notifi...
X Description: The current RequestContext / ServerRequestContext design has a few rough edges that warrant a dedicated refactor: Request vs notification context — Request handlers have request_id and meta, notifi...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2021
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Refactor handler context to be transport- and handler-type-aware","articleBody":"The current `RequestContext` / `ServerRequestContext` design has a few rough edges that warrant a dedicated refactor:\n\n1. **Request vs notification context** — Request handlers have `request_id` and `meta`, notification handlers do not. Currently `request_id` is optional (`RequestId | None`) on a single shared type, which loses type safety. Ideally these would be distinct types so request handlers get a context where `request_id` is always present, and notification handlers get one where it does not exist.\n\n2. **Transport-specific context** — The `request_context` field on `ServerMessageMetadata` is typed as `Any` because the server layer is transport-agnostic (e.g. it is a Starlette `Request` for HTTP transports, `None` for stdio). A better design would let transports provide their own typed context that handlers can access without casting.\n\nThese two concerns are related — both point toward making the context type more precise depending on how and where a handler is invoked.\n\n\u003csub\u003e[AI Disclaimer](https://gist.github.com/maxisbey/6123d132484e4c533eab519a2800693d)\u003c/sub\u003e","author":{"url":"https://github.com/maxisbey","@type":"Person","name":"maxisbey"},"datePublished":"2026-02-09T13:45:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2021/python-sdk/issues/2021"}
| 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:094c69ee-ef17-e650-ac88-ac994df0187e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BEAC:29A644:2DE61F9:3BA57F4:6A5CC96A |
| html-safe-nonce | e23b7c1b7da2809dbf1eb3e34d9185149c246662b4b41c4b18ac13a85a62ddbb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUFDOjI5QTY0NDoyREU2MUY5OjNCQTU3RjQ6NkE1Q0M5NkEiLCJ2aXNpdG9yX2lkIjoiNzE1MzY1Nzg4MzE1ODk1NjM5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 27ea318eb3c8822c7f0f9e4e7453d0d453eb720c774ae0af97bd2986dbebea65 |
| hovercard-subject-tag | issue:3916476512 |
| 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/2021/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fcb97fd0742ab5619136cc7104a472c651de3a957c372dc73ee12c482d0235ca/modelcontextprotocol/python-sdk/issues/2021 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fcb97fd0742ab5619136cc7104a472c651de3a957c372dc73ee12c482d0235ca/modelcontextprotocol/python-sdk/issues/2021 |
| og:image:alt | The current RequestContext / ServerRequestContext design has a few rough edges that warrant a dedicated refactor: Request vs notification context — Request handlers have request_id and meta, notifi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maxisbey |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width