mcp: export ClientSessionOptions.ProtocolVersion (#1127)
## Summary
`ClientSessionOptions.protocolVersion` was unexported and documented as
test-only, so external consumers of `Client.Connect` could not request a
specific protocol revision.
This exports the field as `ProtocolVersion` with the same semantics:
- empty → request the latest supported version (unchanged default)
- non-empty → send that version in initialize/discover
- existing negotiate-down path is unchanged
## Usage
```go
cs, err := client.Connect(ctx, transport, &mcp.ClientSessionOptions{
ProtocolVersion: "2025-11-25",
})
```
## Testing
- `go test ./mcp/ -count=1` (pass)
Fixes #1113
Co-authored-by: arimu1 <19286898+arimu1@users.noreply.github.com>
Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
This commit is contained in:
parent
0d0cdbc943
commit
1acd66e9d7
9 changed files with 73 additions and 72 deletions
|
|
@ -245,11 +245,12 @@ func (e unsupportedProtocolVersionError) Error() string {
|
|||
return fmt.Sprintf("unsupported protocol version: %q", e.version)
|
||||
}
|
||||
|
||||
// ClientSessionOptions is reserved for future use.
|
||||
// ClientSessionOptions configures a client session created by [Client.Connect].
|
||||
type ClientSessionOptions struct {
|
||||
// protocolVersion overrides the protocol version sent in the initialize
|
||||
// request, for testing. If empty, latestProtocolVersion is used.
|
||||
protocolVersion string
|
||||
// ProtocolVersion is the protocol version sent in the initialize (or
|
||||
// discover) request. If empty, the latest supported version is used.
|
||||
// The server may negotiate a different mutually supported version.
|
||||
ProtocolVersion string
|
||||
}
|
||||
|
||||
func (c *Client) capabilities(protocolVersion string) *ClientCapabilities {
|
||||
|
|
@ -311,8 +312,8 @@ func (c *Client) Connect(ctx context.Context, t Transport, opts *ClientSessionOp
|
|||
}
|
||||
|
||||
protocolVersion := latestProtocolVersion
|
||||
if opts != nil && opts.protocolVersion != "" {
|
||||
protocolVersion = opts.protocolVersion
|
||||
if opts != nil && opts.ProtocolVersion != "" {
|
||||
protocolVersion = opts.ProtocolVersion
|
||||
}
|
||||
|
||||
if protocolVersion >= protocolVersion20260728 {
|
||||
|
|
|
|||
|
|
@ -740,7 +740,7 @@ func TestClientConnectDiscover(t *testing.T) {
|
|||
defer ss.Close()
|
||||
|
||||
c := NewClient(testImpl, nil)
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -805,7 +805,7 @@ func TestClientConnectDiscover_RequestContents(t *testing.T) {
|
|||
return nil, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -851,7 +851,7 @@ func TestInMemory_E2E_DiscoverSuccess(t *testing.T) {
|
|||
defer ss.Close()
|
||||
|
||||
client := NewClient(&Implementation{Name: "stdio-like-client", Version: "v1"}, nil)
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect: %v", err)
|
||||
}
|
||||
|
|
@ -908,7 +908,7 @@ func TestInMemory_E2E_DiscoverFallback_NoOverlap(t *testing.T) {
|
|||
defer ss.Close()
|
||||
|
||||
client := NewClient(&Implementation{Name: "new-client", Version: "v1"}, nil)
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect: %v", err)
|
||||
}
|
||||
|
|
@ -955,7 +955,7 @@ func TestInMemory_E2E_DiscoverFallback_MethodNotFound(t *testing.T) {
|
|||
defer ss.Close()
|
||||
|
||||
client := NewClient(&Implementation{Name: "new-client", Version: "v1"}, nil)
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1005,7 +1005,7 @@ func TestInMemory_E2E_DiscoverFallback_UnsupportedProtocolVersion(t *testing.T)
|
|||
defer ss.Close()
|
||||
|
||||
client := NewClient(&Implementation{Name: "new-client", Version: "v1"}, nil)
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1068,7 +1068,7 @@ func TestClientConnectDiscover_UnsupportedVersionNegotiation(t *testing.T) {
|
|||
defer ss.Close()
|
||||
|
||||
c := NewClient(testImpl, nil)
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: unsupportedClientVersion})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: unsupportedClientVersion})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func TestElicitationURLMode(t *testing.T) {
|
|||
},
|
||||
ElicitationHandler: tc.handler,
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ func TestElicitationCompleteNotification(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
defer ss.Close()
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ func TestElicitationNoValidationWithoutAccept(t *testing.T) {
|
|||
return &ElicitResult{Action: tc.action, Content: tc.content}, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ func TestEndToEnd(t *testing.T) {
|
|||
//
|
||||
// Pin the session to 2025-11-25 so the legacy
|
||||
// semantics apply.
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -764,7 +764,7 @@ func TestMiddleware(t *testing.T) {
|
|||
// Pin to 2025-11-25 because the test's expected wire sequence asserts
|
||||
// the legacy initialize / notifications/initialized handshake, which
|
||||
// 2026-07-28 replaces with server/discover.
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -854,7 +854,7 @@ func TestNoJSONNull(t *testing.T) {
|
|||
}
|
||||
|
||||
c := NewClient(testImpl, nil)
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1023,7 +1023,7 @@ func TestElicitationUnsupportedMethod(t *testing.T) {
|
|||
return &CreateMessageResult{Model: "aModel", Content: &TextContent{}}, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1072,7 +1072,7 @@ func TestElicitationSchemaValidation(t *testing.T) {
|
|||
return &ElicitResult{Action: "accept", Content: map[string]any{"test": "value"}}, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1558,7 +1558,7 @@ func TestElicitContentValidation(t *testing.T) {
|
|||
return &ElicitResult{Action: "accept", Content: map[string]any{"test": "potato"}}, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1641,7 +1641,7 @@ func TestElicitationProgressToken(t *testing.T) {
|
|||
return &ElicitResult{Action: "accept"}, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1683,7 +1683,7 @@ func TestElicitationCapabilityDeclaration(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1720,7 +1720,7 @@ func TestElicitationCapabilityDeclaration(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1757,7 +1757,7 @@ func TestElicitationDefaultValues(t *testing.T) {
|
|||
return &ElicitResult{Action: "accept", Content: map[string]any{"default": "response"}}, nil
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1912,7 +1912,7 @@ func TestKeepAliveFailure_Logged(t *testing.T) {
|
|||
// Pin to 2025-11-25: KeepAlive uses the ping RPC, which is removed
|
||||
// in 2026-07-28, so keepalive is only meaningful on legacy protocol
|
||||
// versions.
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -2087,7 +2087,7 @@ func TestSynchronousNotifications(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = ss.Close() })
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -2501,7 +2501,7 @@ func runSubscriptionsListenTest(t *testing.T, client *Client, server *Server, ct
|
|||
ctx, topCancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer topCancel()
|
||||
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -2659,7 +2659,7 @@ func TestSubscriptionsListen_NoHandlersNoListen(t *testing.T) {
|
|||
return next(ctx, method, req)
|
||||
}
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -2782,7 +2782,7 @@ func TestResourceSubscriptions_Streamable(t *testing.T) {
|
|||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL},
|
||||
&ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
&ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -2851,7 +2851,7 @@ func TestResourceSubscriptions_InMemory(t *testing.T) {
|
|||
events <- resourceSubEvent{uri: req.Params.URI, id: id}
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -2928,7 +2928,7 @@ func TestResourceSubscriptions_Subscribe_Idempotent(t *testing.T) {
|
|||
c := NewClient(testImpl, &ClientOptions{
|
||||
ResourceUpdatedHandler: func(context.Context, *ResourceUpdatedNotificationRequest) {},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -3000,7 +3000,7 @@ func TestResourceSubscriptions_MultipleURIs(t *testing.T) {
|
|||
events <- resourceSubEvent{uri: req.Params.URI, id: id}
|
||||
},
|
||||
})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -3105,7 +3105,7 @@ func TestSubscriptionsListen_MultipleSessions(t *testing.T) {
|
|||
}
|
||||
c := newSubListenClient(events)
|
||||
cs, err := c.Connect(context.Background(), ct,
|
||||
&ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
&ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -3205,7 +3205,7 @@ func TestSubscriptionsListen_ResourceListChanged(t *testing.T) {
|
|||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -3249,7 +3249,7 @@ func TestSubscriptionsListen_DisconnectScrubsMaps(t *testing.T) {
|
|||
}
|
||||
c := newSubListenClient(events)
|
||||
cs, err := c.Connect(context.Background(), ct,
|
||||
&ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
&ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client connect: %v", err)
|
||||
}
|
||||
|
|
@ -3428,7 +3428,7 @@ func TestCallCustomMethodTypedNilParams(t *testing.T) {
|
|||
if err := AddSendingCustomMethod[*pingParams, *pingResult](c, "acme/ping"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ func TestMultiRoundTrip_ServerMiddleware(t *testing.T) {
|
|||
},
|
||||
})
|
||||
c.AddRoots(&Root{URI: "file:///workspace", Name: "workspace"})
|
||||
cs, err := c.Connect(t.Context(), ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := c.Connect(t.Context(), ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() error = %v", err)
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ func mustConnect(t *testing.T, s *Server, clientOpts *ClientOptions) *ClientSess
|
|||
})
|
||||
|
||||
c := NewClient(testImpl, clientOpts)
|
||||
cs, err := c.Connect(t.Context(), ct, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := c.Connect(t.Context(), ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() error = %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func TestSamplingWithTools_ToolUse(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ func TestSamplingWithTools_ToolResult(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ func TestSamplingWithTools_ToolResultWithError(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -350,7 +350,7 @@ func TestSamplingWithTools_ParallelToolCalls(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -420,7 +420,7 @@ func TestCreateMessage_MultipleContentError(t *testing.T) {
|
|||
}
|
||||
defer ss.Close()
|
||||
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1663,7 +1663,7 @@ func TestServerSession_RejectsServerInitiated(t *testing.T) {
|
|||
},
|
||||
})
|
||||
c.AddRoots(&Root{URI: "file:///workspace"})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protoVer})
|
||||
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{ProtocolVersion: protoVer})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ func TestStreamableClientTransportLifecycle(t *testing.T) {
|
|||
// Pin to 2025-11-25: the fixture's canned initialize response uses
|
||||
// hardcoded id=1, which only matches when initialize is the first
|
||||
// request. Under 2026-07-28 the client probes server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ func TestStreamableClientRedundantDelete(t *testing.T) {
|
|||
// Pin to 2025-11-25: the fixture's canned initialize response uses
|
||||
// hardcoded id=1, which only matches when initialize is the first
|
||||
// request. Under 2026-07-28 the client probes server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ func TestStreamableClientGETHandling(t *testing.T) {
|
|||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{
|
||||
protocolVersion: protocolVersion20251125,
|
||||
ProtocolVersion: protocolVersion20251125,
|
||||
})
|
||||
if err == nil {
|
||||
defer session.Close()
|
||||
|
|
@ -414,7 +414,7 @@ func TestStreamableClientStrictness(t *testing.T) {
|
|||
// uses hardcoded id=1, which only matches when initialize is
|
||||
// the first request. Under 2026-07-28 the client probes
|
||||
// server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if (err != nil) != test.wantConnectError {
|
||||
t.Errorf("client.Connect() returned error %v; want error: %t", err, test.wantConnectError)
|
||||
}
|
||||
|
|
@ -454,7 +454,7 @@ func TestStreamableClientUnresumableRequest(t *testing.T) {
|
|||
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
client := NewClient(testImpl, nil)
|
||||
cs, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err == nil {
|
||||
cs.Close()
|
||||
t.Fatalf("Connect succeeded unexpectedly")
|
||||
|
|
@ -575,7 +575,7 @@ data: { "jsonrpc": "2.0", "method": "notifications/message", "params": { "level"
|
|||
// uses hardcoded id=1, which only matches when initialize is
|
||||
// the first request. Under 2026-07-28 the client probes
|
||||
// server/discover first.
|
||||
cs, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
cs, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -707,7 +707,7 @@ func TestStreamableClientTransientErrors(t *testing.T) {
|
|||
// uses hardcoded id=1, which only matches when initialize is
|
||||
// the first request. Under 2026-07-28 the client probes
|
||||
// server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect failed: %v", err)
|
||||
}
|
||||
|
|
@ -813,7 +813,7 @@ data: {"jsonrpc":"2.0","method":"notifications/message","params":{"level":"info"
|
|||
// Pin to 2025-11-25: the fixture's canned initialize response uses
|
||||
// hardcoded id=1, which only matches when initialize is the first
|
||||
// request. Under 2026-07-28 the client probes server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect failed: %v", err)
|
||||
}
|
||||
|
|
@ -901,7 +901,7 @@ func TestStreamableClientDisableStandaloneSSE(t *testing.T) {
|
|||
// uses hardcoded id=1, which only matches when initialize is
|
||||
// the first request. Under 2026-07-28 the client probes
|
||||
// server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -1022,7 +1022,7 @@ func TestStreamableClientOAuth_AuthorizationHeader(t *testing.T) {
|
|||
// Pin to 2025-11-25: the fixture's canned initialize response uses
|
||||
// hardcoded id=1, which only matches when initialize is the first
|
||||
// request. Under 2026-07-28 the client probes server/discover first.
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -1316,7 +1316,7 @@ func TestStreamableClientConnect_DiscoverSuccess(t *testing.T) {
|
|||
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1496,7 +1496,7 @@ func TestStreamableClientConnect_DiscoverMethodNotFound(t *testing.T) {
|
|||
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1563,7 +1563,7 @@ func TestStreamableClientConnect_DiscoverUnsupportedVersion(t *testing.T) {
|
|||
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1623,7 +1623,7 @@ func TestStreamableClientConnect_DiscoverMethodNotFoundVPre(t *testing.T) {
|
|||
DisableStandaloneSSE: true,
|
||||
}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1680,7 +1680,7 @@ func TestStreamableClientConnect_DiscoverUnsupportedVersionVPre(t *testing.T) {
|
|||
DisableStandaloneSSE: true,
|
||||
}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -1738,7 +1738,7 @@ func TestStreamableClientConnect_DiscoverUnsupportedVersionNegotiation(t *testin
|
|||
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: unsupportedClientVersion})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: unsupportedClientVersion})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ func TestStreamableServerShutdown(t *testing.T) {
|
|||
clientSession, err := client.Connect(ctx, &StreamableClientTransport{
|
||||
Endpoint: httpServer.URL,
|
||||
MaxRetries: -1, // avoid slow tests during exponential retries
|
||||
}, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
}, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -622,7 +622,7 @@ func TestStreamableServerDisconnect(t *testing.T) {
|
|||
})
|
||||
clientSession, err := client.Connect(ctx, &StreamableClientTransport{
|
||||
Endpoint: httpServer.URL,
|
||||
}, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
}, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -697,7 +697,7 @@ func TestServerTransportCleanup(t *testing.T) {
|
|||
// stateful HTTP server (which rejects the new protocol), opening
|
||||
// an extra HTTP connection and therefore an extra session. Pinning
|
||||
// to 2025-11-25 skips the discover probe.
|
||||
clientSession, err := client.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL}, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
clientSession, err := client.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL}, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -2122,7 +2122,7 @@ func TestStreamableMcpHeaderValidationErrorFormat(t *testing.T) {
|
|||
|
||||
client := NewClient(&Implementation{Name: "testClient", Version: "v1.0.0"}, nil)
|
||||
ctx := context.Background()
|
||||
session, err := client.Connect(ctx, clientTransport, &ClientSessionOptions{protocolVersion: minVersionForStandardHeaders})
|
||||
session, err := client.Connect(ctx, clientTransport, &ClientSessionOptions{ProtocolVersion: minVersionForStandardHeaders})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -2285,7 +2285,7 @@ func TestStreamableParamHeadersClientSetsHeaders(t *testing.T) {
|
|||
|
||||
client := NewClient(&Implementation{Name: "testClient", Version: "v1.0.0"}, nil)
|
||||
ctx := context.Background()
|
||||
session, err := client.Connect(ctx, clientTransport, &ClientSessionOptions{protocolVersion: minVersionForStandardHeaders})
|
||||
session, err := client.Connect(ctx, clientTransport, &ClientSessionOptions{ProtocolVersion: minVersionForStandardHeaders})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -2383,7 +2383,7 @@ func TestStreamableFilterValidToolsIntegration(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
session, err := client.Connect(ctx, &StreamableClientTransport{
|
||||
Endpoint: httpServer.URL,
|
||||
}, &ClientSessionOptions{protocolVersion: minVersionForStandardHeaders})
|
||||
}, &ClientSessionOptions{ProtocolVersion: minVersionForStandardHeaders})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -2644,7 +2644,7 @@ func TestStreamableSessionTimeout(t *testing.T) {
|
|||
// protocol), opening an extra HTTP connection and therefore an extra
|
||||
// session. Pinning to 2025-11-25 skips the discover probe.
|
||||
client := NewClient(testImpl, nil)
|
||||
session, err := client.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL}, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL}, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("client.Connect() failed: %v", err)
|
||||
}
|
||||
|
|
@ -2938,7 +2938,7 @@ func Test_ExportErrSessionMissing(t *testing.T) {
|
|||
// first against a stateful HTTP server (which rejects the new
|
||||
// protocol), opening an extra HTTP connection and therefore an extra
|
||||
// session. Pinning to 2025-11-25 skips the discover probe.
|
||||
session, err := client.Connect(ctx, clientTransport, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
|
||||
session, err := client.Connect(ctx, clientTransport, &ClientSessionOptions{ProtocolVersion: protocolVersion20251125})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect failed: %v", err)
|
||||
}
|
||||
|
|
@ -3579,7 +3579,7 @@ func TestStreamableClientUnsupportedVersionFallback(t *testing.T) {
|
|||
client := NewClient(testImpl, nil)
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
session, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
@ -3771,7 +3771,7 @@ func TestStreamableHTTP_E2E_DiscoverSuccess(t *testing.T) {
|
|||
|
||||
client := NewClient(&Implementation{Name: "e2e-client", Version: "v1"}, nil)
|
||||
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
|
||||
cs, err := client.Connect(ctx, transport, &ClientSessionOptions{protocolVersion: protocolVersion20260728})
|
||||
cs, err := client.Connect(ctx, transport, &ClientSessionOptions{ProtocolVersion: protocolVersion20260728})
|
||||
if err != nil {
|
||||
t.Fatalf("Connect: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue