@@ -10,7 +10,6 @@ import (
1010 "context"
1111 "fmt"
1212 "log/slog"
13- "slices"
1413 "sync/atomic"
1514 "testing"
1615
@@ -644,13 +643,6 @@ func TestClientCapabilitiesOverWire(t *testing.T) {
644643// don't overlap with the SDK. The test then asserts the resulting session
645644// state and whether the legacy initialize handshake ran.
646645func TestClientConnectDiscover (t * testing.T ) {
647- // Temporarily enable 2026-07-28 support in the SDK for this test
648- oldSupported := supportedProtocolVersions
649- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, supportedProtocolVersions ... )
650- t .Cleanup (func () {
651- supportedProtocolVersions = oldSupported
652- })
653-
654646 const otherVersionsOnly = "1999-01-01"
655647
656648 tests := []struct {
@@ -686,7 +678,7 @@ func TestClientConnectDiscover(t *testing.T) {
686678 return nil , jsonrpc2 .ErrMethodNotFound
687679 },
688680 wantInitialize : true ,
689- wantVersion : latestProtocolVersion ,
681+ wantVersion : protocolVersion20251125 ,
690682 },
691683 {
692684 name : "unsupported protocol version falls back to initialize" ,
@@ -697,7 +689,7 @@ func TestClientConnectDiscover(t *testing.T) {
697689 }
698690 },
699691 wantInitialize : true ,
700- wantVersion : latestProtocolVersion ,
692+ wantVersion : protocolVersion20251125 ,
701693 },
702694 {
703695 name : "no overlapping supported version falls back to initialize" ,
@@ -709,7 +701,7 @@ func TestClientConnectDiscover(t *testing.T) {
709701 }, nil
710702 },
711703 wantInitialize : true ,
712- wantVersion : latestProtocolVersion ,
704+ wantVersion : protocolVersion20251125 ,
713705 },
714706 }
715707
@@ -771,10 +763,6 @@ func TestClientConnectDiscover(t *testing.T) {
771763// request sent by Client.Connect carries the SEP-2575 per-request _meta triple:
772764// protocolVersion, clientInfo, and clientCapabilities.
773765func TestClientConnectDiscover_RequestContents (t * testing.T ) {
774- orig := supportedProtocolVersions
775- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, slices .Clone (orig )... )
776- t .Cleanup (func () { supportedProtocolVersions = orig })
777-
778766 ctx := context .Background ()
779767
780768 type captured struct {
@@ -850,10 +838,6 @@ func TestClientConnectDiscover_RequestContents(t *testing.T) {
850838func TestInMemory_E2E_DiscoverSuccess (t * testing.T ) {
851839 ctx := context .Background ()
852840
853- orig := supportedProtocolVersions
854- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, slices .Clone (orig )... )
855- t .Cleanup (func () { supportedProtocolVersions = orig })
856-
857841 server := NewServer (& Implementation {Name : "stdio-like-server" , Version : "v1" }, nil )
858842 ct , st := NewInMemoryTransports ()
859843 ss , err := server .Connect (ctx , st , nil )
@@ -889,15 +873,11 @@ func TestInMemory_E2E_DiscoverSuccess(t *testing.T) {
889873
890874// TestInMemory_E2E_DiscoverFallback_NoOverlap verifies the fallback path
891875// over an InMemory (STDIO-equivalent) transport: the client probes with
892- // _meta.protocolVersion = 2026-07-28, but the server's supported list does
893- // NOT include that version (the default for an SDK server that hasn't
894- // shimmed supportedProtocolVersions) .
876+ // _meta.protocolVersion = 2026-07-28, but the server overrides discover via
877+ // middleware to advertise only legacy versions, so the client must fall
878+ // back to the legacy initialize handshake .
895879func TestInMemory_E2E_DiscoverFallback_NoOverlap (t * testing.T ) {
896880 ctx := context .Background ()
897- orig := supportedProtocolVersions
898- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, slices .Clone (orig )... )
899- t .Cleanup (func () { supportedProtocolVersions = orig })
900-
901881 server := NewServer (& Implementation {Name : "vpre-like-server" , Version : "v1" }, nil )
902882 // Intercept discover and reply as if we were a server that only
903883 // supports legacy versions.
@@ -932,9 +912,11 @@ func TestInMemory_E2E_DiscoverFallback_NoOverlap(t *testing.T) {
932912 if ir == nil {
933913 t .Fatal ("InitializeResult is nil after fallback initialize" )
934914 }
935- if ir .ProtocolVersion != latestProtocolVersion {
915+ // The fallback initialize explicitly requests protocolVersion20251125
916+ // (see client.go), so the server negotiates that version.
917+ if ir .ProtocolVersion != protocolVersion20251125 {
936918 t .Errorf ("InitializeResult.ProtocolVersion = %q, want %q (legacy fallback after no-overlap discover)" ,
937- ir .ProtocolVersion , latestProtocolVersion )
919+ ir .ProtocolVersion , protocolVersion20251125 )
938920 }
939921
940922 // Prove the session is usable after fallback.
@@ -949,10 +931,6 @@ func TestInMemory_E2E_DiscoverFallback_NoOverlap(t *testing.T) {
949931func TestInMemory_E2E_DiscoverFallback_MethodNotFound (t * testing.T ) {
950932 ctx := context .Background ()
951933
952- orig := supportedProtocolVersions
953- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, slices .Clone (orig )... )
954- t .Cleanup (func () { supportedProtocolVersions = orig })
955-
956934 server := NewServer (& Implementation {Name : "vpre-server" , Version : "v1" }, nil )
957935 server .AddReceivingMiddleware (func (next MethodHandler ) MethodHandler {
958936 return func (ctx context.Context , method string , req Request ) (Result , error ) {
@@ -981,9 +959,11 @@ func TestInMemory_E2E_DiscoverFallback_MethodNotFound(t *testing.T) {
981959 if ir == nil {
982960 t .Fatal ("InitializeResult is nil after fallback initialize" )
983961 }
984- if ir .ProtocolVersion != latestProtocolVersion {
962+ // The fallback initialize explicitly requests protocolVersion20251125
963+ // (see client.go), so the server negotiates that version.
964+ if ir .ProtocolVersion != protocolVersion20251125 {
985965 t .Errorf ("InitializeResult.ProtocolVersion = %q, want %q (legacy fallback after MethodNotFound)" ,
986- ir .ProtocolVersion , latestProtocolVersion )
966+ ir .ProtocolVersion , protocolVersion20251125 )
987967 }
988968
989969 if _ , err := cs .ListTools (ctx , nil ); err != nil {
@@ -998,10 +978,6 @@ func TestInMemory_E2E_DiscoverFallback_MethodNotFound(t *testing.T) {
998978func TestInMemory_E2E_DiscoverFallback_UnsupportedProtocolVersion (t * testing.T ) {
999979 ctx := context .Background ()
1000980
1001- orig := supportedProtocolVersions
1002- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, slices .Clone (orig )... )
1003- t .Cleanup (func () { supportedProtocolVersions = orig })
1004-
1005981 server := NewServer (& Implementation {Name : "strict-server" , Version : "v1" }, nil )
1006982 server .AddReceivingMiddleware (func (next MethodHandler ) MethodHandler {
1007983 return func (ctx context.Context , method string , req Request ) (Result , error ) {
@@ -1033,9 +1009,11 @@ func TestInMemory_E2E_DiscoverFallback_UnsupportedProtocolVersion(t *testing.T)
10331009 if ir == nil {
10341010 t .Fatal ("InitializeResult is nil after fallback initialize" )
10351011 }
1036- if ir .ProtocolVersion != latestProtocolVersion {
1012+ // The fallback initialize explicitly requests protocolVersion20251125
1013+ // (see client.go), so the server negotiates that version.
1014+ if ir .ProtocolVersion != protocolVersion20251125 {
10371015 t .Errorf ("InitializeResult.ProtocolVersion = %q, want %q (legacy fallback after UnsupportedProtocolVersion)" ,
1038- ir .ProtocolVersion , latestProtocolVersion )
1016+ ir .ProtocolVersion , protocolVersion20251125 )
10391017 }
10401018}
10411019
@@ -1045,10 +1023,6 @@ func TestInMemory_E2E_DiscoverFallback_UnsupportedProtocolVersion(t *testing.T)
10451023// UnsupportedProtocolVersionError carries Data.Supported, and the client
10461024// selects a mutually supported version from that list and retries.
10471025func TestClientConnectDiscover_UnsupportedVersionNegotiation (t * testing.T ) {
1048- oldSupported := supportedProtocolVersions
1049- supportedProtocolVersions = append ([]string {protocolVersion20260728 }, slices .Clone (oldSupported )... )
1050- t .Cleanup (func () { supportedProtocolVersions = oldSupported })
1051-
10521026 ctx := context .Background ()
10531027
10541028 const unsupportedClientVersion = "2099-12-31"
0 commit comments