Uh oh!
There was an error while loading. Please reload this page.
feat: add claims field to AccessToken for decoded token payload - #1165
feat: add claims field to AccessToken for decoded token payload#1165robertofalk wants to merge 9 commits into
Conversation
robertofalk
commented
Jul 22, 2025
ochafik
left a comment
There was a problem hiding this comment.
Hi @robertofalk, thanks for sending this PR!
Currently, there is no JWT payload used to build the AccessToken, afaict.
To handle JWT tokens, you might want to create a new JWTAccessToken / created by a new JWTTokenVerifier (responsible for verifying the token signature), used by a JWT-specific OAuthAuthorizationServerProvider subclass distinct from SimpleOAuthProvider.
(and if we get there, I reckon the non-standard claims should go to a JWTAccessToken.additional_claims field to avoid duplication)
Does this make sense?
felixweinberger
commented
Sep 26, 2025
Closing this as per @ochafik's comment this is incomplete and it's been a while since the last update here. If others find this PR and need this, feel free to submit a fresh PR. |
Add optional claims dict to AccessToken class to provide access to all decoded JWT claims (both standard and custom) instead of restricting to only specific fields like scopes and expires_at.
Motivation and Context
FastMCP provides a BearerAuthProvider class to validate bearer tokens and returns it using the AccessToken class (https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/providers/bearer.py#L387). With the current implementation the claims from the token are limited to the ones defined so far, so any additional claim is not available and to get it currently I had to define an additional middleware that decodes the token again, which is a waste since the token is was already decoded by BearerAuthProvider.
How Has This Been Tested?
I was not able to test it since it's just an attribute that will be used by applications relying on the python-sdk AccessToken class.
Breaking Changes
No, it's an optional attribute.
Types of changes
Checklist
Resolves#1038