Title: MCP server: AccessToken class should have field for subject claim ("sub") · Issue #1038 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: MCP server: AccessToken class should have field for subject claim ("sub") · Issue #1038 · modelcontextprotocol/python-sdk
X Title: MCP server: AccessToken class should have field for subject claim ("sub") · Issue #1038 · modelcontextprotocol/python-sdk
Description: Description I'm proposing to add subject to AccessToken in mcp/server/auth/provider.py, which can be used to store the sub JWT claim that usually corresponds to the user ID: class AccessToken(BaseModel): token: str client_id: str scopes:...
Open Graph Description: Description I'm proposing to add subject to AccessToken in mcp/server/auth/provider.py, which can be used to store the sub JWT claim that usually corresponds to the user ID: class AccessToken(BaseM...
X Description: Description I'm proposing to add subject to AccessToken in mcp/server/auth/provider.py, which can be used to store the sub JWT claim that usually corresponds to the user ID: class AccessToken(B...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/1038
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP server: AccessToken class should have field for subject claim (\"sub\")","articleBody":"### Description\n\nI'm proposing to add `subject` to `AccessToken` in `mcp/server/auth/provider.py`, which can be used to store the `sub` JWT claim that usually corresponds to the user ID:\n```\nclass AccessToken(BaseModel):\n token: str\n client_id: str\n scopes: list[str]\n expires_at: int | None = None\n resource: str | None = None # RFC 8707 resource indicator\n\n # Proposed:\n subject: str | None = None # Subject (user ID)\n```\n\nThen we can implement a token verifier as follows:\n\n```\nclass MyTokenVerifier:\n async def verify_token(self, token: str) -> AccessToken | None:\n try:\n token_claims = decode_and_validate_jwt(token)\n except ...:\n return None\n\n return AccessToken(\n token=token,\n ...\n subject=token_claims[\"sub\"],\n )\n```\n\nand directly retrieve the user ID from the auth token in the context:\n\n```\nfrom mcp.server.auth.middleware.auth_context import get_access_token\n\nuser_id = get_access_token().subject\n```\n\n### References\n\n_No response_","author":{"url":"https://github.com/thomasst","@type":"Person","name":"thomasst"},"datePublished":"2025-06-26T11:08:56Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/1038"}
| 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:9940825f-61e7-c560-a516-fabe8a2f3ab7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF2C:39F674:FD4D6:14D83C:6AFD1E9C |
| html-safe-nonce | 0a9a876aa6f63e88488100c6e3cdce6db41d0f11bebc007c360ade73e12c7bb6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjJDOjM5RjY3NDpGRDRENjoxNEQ4M0M6NkFGRDFFOUMiLCJ2aXNpdG9yX2lkIjoiNDI2MDMwNjE1NTgwMjAwOTI0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 38f1763d48d94ed294d5fcd9598efa765ee91c4788a1adf5eafacd45953bd9e0 |
| hovercard-subject-tag | issue:3178744615 |
| 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/1038/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42f0eee50768d2094138afb829523f468c950dae0a3d8bd690f534c29e2578a1/modelcontextprotocol/python-sdk/issues/1038 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42f0eee50768d2094138afb829523f468c950dae0a3d8bd690f534c29e2578a1/modelcontextprotocol/python-sdk/issues/1038 |
| og:image:alt | Description I'm proposing to add subject to AccessToken in mcp/server/auth/provider.py, which can be used to store the sub JWT claim that usually corresponds to the user ID: class AccessToken(BaseM... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thomasst |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| 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 | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width