From ec564f9ccb6e9d6d1abe31f974a552acc23e1355 Mon Sep 17 00:00:00 2001 From: Guglielmo Colombo Date: Mon, 6 Jul 2026 17:40:27 +0200 Subject: [PATCH] mcp: cap negotiated protocolVersion in legacy initialize to `protocolVersion20251125` (#1051) Fixes #1033 --- mcp/shared.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mcp/shared.go b/mcp/shared.go index c5d81e6..0fc19c5 100644 --- a/mcp/shared.go +++ b/mcp/shared.go @@ -57,15 +57,13 @@ func negotiatedVersion(clientVersion string) string { // In general, prefer to use the clientVersion, but if we don't support the // client's version, use the latest version. // - // This handles the case where a new spec version is released, and the SDK - // does not support it yet. // Cap the supported versions at the legacy protocolVersion20251125, as this // method is used by the initialize method which is deprecated in // version protocolVersion20260728. - if !slices.Contains(supportedProtocolVersions, clientVersion) { - return protocolVersion20251125 + if slices.Contains(supportedProtocolVersions, clientVersion) && clientVersion < protocolVersion20260728 { + return clientVersion } - return clientVersion + return protocolVersion20251125 } // negotiateMutuallySupportedVersion returns a protocol version that is supported