File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def __init__(
119119 logging_callback : LoggingFnT | None = None ,
120120 message_handler : MessageHandlerFnT | None = None ,
121121 client_info : types .Implementation | None = None ,
122+ protocol_version : str | None = None ,
122123 ) -> None :
123124 super ().__init__ (
124125 read_stream ,
@@ -128,6 +129,7 @@ def __init__(
128129 read_timeout_seconds = read_timeout_seconds ,
129130 )
130131 self ._client_info = client_info or DEFAULT_CLIENT_INFO
132+ self ._protocol_version = protocol_version or types .LATEST_PROTOCOL_VERSION
131133 self ._sampling_callback = sampling_callback or _default_sampling_callback
132134 self ._elicitation_callback = elicitation_callback or _default_elicitation_callback
133135 self ._list_roots_callback = list_roots_callback or _default_list_roots_callback
@@ -153,7 +155,7 @@ async def initialize(self) -> types.InitializeResult:
153155 types .ClientRequest (
154156 types .InitializeRequest (
155157 params = types .InitializeRequestParams (
156- protocolVersion = types . LATEST_PROTOCOL_VERSION ,
158+ protocolVersion = self . _protocol_version ,
157159 capabilities = types .ClientCapabilities (
158160 sampling = sampling ,
159161 elicitation = elicitation ,
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ async def create_connected_server_and_client_session(
6161 client_info : types .Implementation | None = None ,
6262 raise_exceptions : bool = False ,
6363 elicitation_callback : ElicitationFnT | None = None ,
64+ protocol_version : str | None = None ,
6465) -> AsyncGenerator [ClientSession , None ]:
6566 """Creates a ClientSession that is connected to a running MCP server."""
6667 async with create_client_server_memory_streams () as (
@@ -92,6 +93,7 @@ async def create_connected_server_and_client_session(
9293 message_handler = message_handler ,
9394 client_info = client_info ,
9495 elicitation_callback = elicitation_callback ,
96+ protocol_version = protocol_version ,
9597 ) as client_session :
9698 await client_session .initialize ()
9799 yield client_session
You can’t perform that action at this time.
0 commit comments