-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Issue 687 fix #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Vinisha-projects
wants to merge
22
commits into
modelcontextprotocol:main
Choose a base branch
from
Vinisha-projects:issue-687-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Issue 687 fix #747
Vinisha-projects
wants to merge
22
commits into
modelcontextprotocol:main
from
Vinisha-projects:issue-687-fix
+12,269
−12,125
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements authorization support as per RFC 9728 (#686).
It introduces robust token generation and validation methods, fully aligned with the new MCP authorization specification.
The changes include:
Implementation of token generation using JWT with proper encoding and expiration.
Validation of JWT tokens with issuer and audience verification.
Error handling for expired or invalid tokens.
Unit tests for token generation, validation, claim extraction, and expiration scenarios.
Motivation and Context
The primary motivation for this change is to ensure MCP Python SDK’s compliance with RFC 9728, the new authorization specification.
By adding proper token management, it
*Enhances security by leveraging JWT-based authentication.
*Aligns with the authorization standards outlined in the MCP specification.
*Provides a robust framework for secure client-server communication.
*This change addresses Issue #686 by implementing the authorization flow, including token creation, validation, and handling edge cases like expiration and invalid claims.
How Has This Been Tested?
*All unit tests have been executed and passed successfully, covering the following scenarios:
*Generating a valid token and verifying its claims.
*Detecting an expired token.
*Extracting a specific claim from a valid token.
*Handling a token with invalid claims.
Handling a completely invalid or malformed token.
Breaking Changes
None.
The introduced features are additive and do not affect existing functionality.
Types of changes
Checklist
Additional context
This feature aligns the MCP Python SDK with the latest authorization standards as outlined in RFC 9728.
It also improves security practices by ensuring token validity and proper claim extraction in a structured and standardized way.