feat: Add protocol_version parameter to ClientSession#2313
Closed
goingforstudying-ctrl wants to merge 2 commits intomodelcontextprotocol:mainfrom
Closed
feat: Add protocol_version parameter to ClientSession#2313goingforstudying-ctrl wants to merge 2 commits intomodelcontextprotocol:mainfrom
goingforstudying-ctrl wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
added 2 commits
March 19, 2026 21:23
Add optional protocol_version parameter to ClientSession.__init__() to allow callers to override the default LATEST_PROTOCOL_VERSION when connecting to servers that require a specific protocol version. Fixes modelcontextprotocol#2307
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.
Summary
Add optional
protocol_versionparameter toClientSession.__init__()to allow callers to override the defaultLATEST_PROTOCOL_VERSIONwhen connecting to servers that require a specific protocol version.Changes
protocol_version: str | None = Noneparameter toClientSession.__init__()self._protocol_version(defaults toLATEST_PROTOCOL_VERSION)self._protocol_versionininitialize()instead of hardcoded constantBackwards Compatibility
This is a non-breaking change. Existing callers will continue to use
LATEST_PROTOCOL_VERSIONas the default. Callers that need a specific version can pass it explicitly.Example Usage
Fixes #2307