From 5fa31c3d9189767d3697d1a45b2aee82577550c6 Mon Sep 17 00:00:00 2001 From: PR-Contributor Date: Thu, 19 Mar 2026 21:23:27 +0000 Subject: [PATCH 1/3] feat: Add protocol_version parameter to ClientSession 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 #2307 --- src/mcp/client/session.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mcp/client/session.py b/src/mcp/client/session.py index a0ca751bd..da821cac9 100644 --- a/src/mcp/client/session.py +++ b/src/mcp/client/session.py @@ -121,6 +121,7 @@ def __init__( *, sampling_capabilities: types.SamplingCapability | None = None, experimental_task_handlers: ExperimentalTaskHandlers | None = None, + protocol_version: str | None = None, ) -> None: super().__init__(read_stream, write_stream, read_timeout_seconds=read_timeout_seconds) self._client_info = client_info or DEFAULT_CLIENT_INFO @@ -136,6 +137,9 @@ def __init__( # Experimental: Task handlers (use defaults if not provided) self._task_handlers = experimental_task_handlers or ExperimentalTaskHandlers() + + # Protocol version (defaults to LATEST_PROTOCOL_VERSION) + self._protocol_version = protocol_version or types.LATEST_PROTOCOL_VERSION @property def _receive_request_adapter(self) -> TypeAdapter[types.ServerRequest]: @@ -168,7 +172,7 @@ async def initialize(self) -> types.InitializeResult: result = await self.send_request( types.InitializeRequest( params=types.InitializeRequestParams( - protocol_version=types.LATEST_PROTOCOL_VERSION, + protocol_version=self._protocol_version, capabilities=types.ClientCapabilities( sampling=sampling, elicitation=elicitation, From c0647e674c26b567b35886e23013bdd1bc7a63b5 Mon Sep 17 00:00:00 2001 From: PR-Contributor Date: Thu, 19 Mar 2026 22:25:44 +0000 Subject: [PATCH 2/3] fix: Align ElicitResult action naming with specification Change action value from "decline" to "reject" to match the MCP specification. The specification defines three actions for Elicitation: - accept - reject - cancel But the Python SDK was using "decline" instead of "reject". This fixes the inconsistency between the SDK and the specification. Fixes #1056 --- src/mcp/types/_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mcp/types/_types.py b/src/mcp/types/_types.py index 9005d253a..26d6abdc2 100644 --- a/src/mcp/types/_types.py +++ b/src/mcp/types/_types.py @@ -1688,11 +1688,11 @@ class ElicitRequest(Request[ElicitRequestParams, Literal["elicitation/create"]]) class ElicitResult(Result): """The client's response to an elicitation request.""" - action: Literal["accept", "decline", "cancel"] + action: Literal["accept", "reject", "cancel"] """ The user action in response to the elicitation. - "accept": User submitted the form/confirmed the action (or consented to URL navigation) - - "decline": User explicitly declined the action + - "reject": User explicitly rejected the action - "cancel": User dismissed without making an explicit choice """ From 09292d71c15c830344ab05b13b2a2b747c920772 Mon Sep 17 00:00:00 2001 From: goingforstudying-ctrl Date: Fri, 20 Mar 2026 03:07:57 +0000 Subject: [PATCH 3/3] style: fix pre-commit formatting (trailing whitespace) --- src/mcp/client/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mcp/client/session.py b/src/mcp/client/session.py index da821cac9..bb888723e 100644 --- a/src/mcp/client/session.py +++ b/src/mcp/client/session.py @@ -137,7 +137,7 @@ def __init__( # Experimental: Task handlers (use defaults if not provided) self._task_handlers = experimental_task_handlers or ExperimentalTaskHandlers() - + # Protocol version (defaults to LATEST_PROTOCOL_VERSION) self._protocol_version = protocol_version or types.LATEST_PROTOCOL_VERSION