Skip to content

Commit 23b1b68

Browse files
committed
address review comments
1 parent ba3dea7 commit 23b1b68

File tree

4 files changed

+24
-29
lines changed

4 files changed

+24
-29
lines changed

mcp/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (c *Client) capabilities() *ClientCapabilities {
130130
caps := &ClientCapabilities{}
131131
// Due to an oversight (#607), roots require special handling.
132132
caps.Roots.ListChanged = true
133-
caps.RootsV2 = &RootsCapabilities{
133+
caps.RootsV2 = &RootCapabilities{
134134
ListChanged: true,
135135
}
136136
if c.opts.CreateMessageHandler != nil {

mcp/client_test.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ func TestClientPaginateVariousPageSizes(t *testing.T) {
192192
}
193193

194194
func TestClientCapabilities(t *testing.T) {
195-
canListRoots := RootsCapabilities{ListChanged: true}
196195
testCases := []struct {
197196
name string
198197
configureClient func(s *Client)
@@ -203,8 +202,8 @@ func TestClientCapabilities(t *testing.T) {
203202
name: "With initial capabilities",
204203
configureClient: func(s *Client) {},
205204
wantCapabilities: &ClientCapabilities{
206-
Roots: canListRoots,
207-
RootsV2: &canListRoots,
205+
Roots: RootCapabilities{ListChanged: true},
206+
RootsV2: &RootCapabilities{ListChanged: true},
208207
},
209208
},
210209
{
@@ -216,8 +215,8 @@ func TestClientCapabilities(t *testing.T) {
216215
},
217216
},
218217
wantCapabilities: &ClientCapabilities{
219-
Roots: canListRoots,
220-
RootsV2: &canListRoots,
218+
Roots: RootCapabilities{ListChanged: true},
219+
RootsV2: &RootCapabilities{ListChanged: true},
221220
Sampling: &SamplingCapabilities{},
222221
},
223222
},
@@ -231,8 +230,8 @@ func TestClientCapabilities(t *testing.T) {
231230
},
232231
},
233232
wantCapabilities: &ClientCapabilities{
234-
Roots: canListRoots,
235-
RootsV2: &canListRoots,
233+
Roots: RootCapabilities{ListChanged: true},
234+
RootsV2: &RootCapabilities{ListChanged: true},
236235
Elicitation: &ElicitationCapabilities{
237236
Form: &FormElicitationCapabilities{},
238237
},
@@ -248,10 +247,8 @@ func TestClientCapabilities(t *testing.T) {
248247
},
249248
},
250249
wantCapabilities: &ClientCapabilities{
251-
Roots: struct {
252-
ListChanged bool "json:\"listChanged,omitempty\""
253-
}{ListChanged: true},
254-
RootsV2: &RootsCapabilities{ListChanged: true},
250+
Roots: RootCapabilities{ListChanged: true},
251+
RootsV2: &RootCapabilities{ListChanged: true},
255252
Elicitation: &ElicitationCapabilities{
256253
URL: &URLElicitationCapabilities{},
257254
},
@@ -267,10 +264,8 @@ func TestClientCapabilities(t *testing.T) {
267264
},
268265
},
269266
wantCapabilities: &ClientCapabilities{
270-
Roots: struct {
271-
ListChanged bool "json:\"listChanged,omitempty\""
272-
}{ListChanged: true},
273-
RootsV2: &RootsCapabilities{ListChanged: true},
267+
Roots: RootCapabilities{ListChanged: true},
268+
RootsV2: &RootCapabilities{ListChanged: true},
274269
Elicitation: &ElicitationCapabilities{
275270
Form: &FormElicitationCapabilities{},
276271
URL: &URLElicitationCapabilities{},

mcp/protocol.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ func (x *CancelledParams) isParams() {}
177177
func (x *CancelledParams) GetProgressToken() any { return getProgressToken(x) }
178178
func (x *CancelledParams) SetProgressToken(t any) { setProgressToken(x, t) }
179179

180-
// RootsCapabilities describes a client's support for roots.
181-
type RootsCapabilities struct {
180+
// RootCapabilities describes a client's support for roots.
181+
type RootCapabilities struct {
182182
// ListChanged reports whether the client supports notifications for
183183
// changes to the roots list.
184184
ListChanged bool `json:"listChanged,omitempty"`
@@ -193,15 +193,15 @@ type ClientCapabilities struct {
193193
// Roots describes the client's support for roots.
194194
//
195195
// Deprecated: use RootsV2. As described in #607, Roots should have been a
196-
// pointer to a RootsCapabilities value. Roots will be continue to be
196+
// pointer to a RootCapabilities value. Roots will be continue to be
197197
// populated, but any new fields will only be added in the RootsV2 field.
198198
Roots struct {
199199
// ListChanged reports whether the client supports notifications for
200200
// changes to the roots list.
201201
ListChanged bool `json:"listChanged,omitempty"`
202202
} `json:"roots,omitempty"`
203203
// RootsV2 is present if the client supports roots.
204-
RootsV2 *RootsCapabilities `json:"-"`
204+
RootsV2 *RootCapabilities `json:"-"`
205205
// Sampling is present if the client supports sampling from an LLM.
206206
Sampling *SamplingCapabilities `json:"sampling,omitempty"`
207207
// Elicitation is present if the client supports elicitation from the server.
@@ -217,10 +217,10 @@ func (c *ClientCapabilities) toV2() *clientCapabilitiesV2 {
217217

218218
// clientCapabilitiesV2 is a version of ClientCapabilities that fixes the bug
219219
// described in #607: Roots should have been a pointer to value type
220-
// RootsCapabilities.
220+
// RootCapabilities.
221221
type clientCapabilitiesV2 struct {
222222
ClientCapabilities
223-
Roots *RootsCapabilities `json:"roots,omitempty"`
223+
Roots *RootCapabilities `json:"roots,omitempty"`
224224
}
225225

226226
func (c *clientCapabilitiesV2) toV1() *ClientCapabilities {

mcp/server_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,14 @@ func testToolForSchema[In, Out any](t *testing.T, tool *Tool, in string, out Out
601601
}
602602
}
603603

604-
// TestClientRootsCapabilities verifies that the server correctly observes
604+
// TestClientRootCapabilities verifies that the server correctly observes
605605
// RootsV2 for various client capability configurations. This tests the fix
606606
// for #607.
607-
func TestClientRootsCapabilities(t *testing.T) {
607+
func TestClientRootCapabilities(t *testing.T) {
608608
testCases := []struct {
609609
name string
610610
capabilities *string // JSON for the capabilities field; nil means omit the field
611-
wantRootsV2 *RootsCapabilities
611+
wantRootsV2 *RootCapabilities
612612
}{
613613
{
614614
name: "capabilities field omitted",
@@ -628,17 +628,17 @@ func TestClientRootsCapabilities(t *testing.T) {
628628
{
629629
name: "capabilities with empty roots",
630630
capabilities: ptr(`{"roots": {}}`),
631-
wantRootsV2: &RootsCapabilities{ListChanged: false},
631+
wantRootsV2: &RootCapabilities{ListChanged: false},
632632
},
633633
{
634634
name: "capabilities with roots without listChanged",
635635
capabilities: ptr(`{"roots": {"listChanged": false}}`),
636-
wantRootsV2: &RootsCapabilities{ListChanged: false},
636+
wantRootsV2: &RootCapabilities{ListChanged: false},
637637
},
638638
{
639639
name: "capabilities with roots with listChanged",
640640
capabilities: ptr(`{"roots": {"listChanged": true}}`),
641-
wantRootsV2: &RootsCapabilities{ListChanged: true},
641+
wantRootsV2: &RootCapabilities{ListChanged: true},
642642
},
643643
}
644644

@@ -706,7 +706,7 @@ func TestClientRootsCapabilities(t *testing.T) {
706706
t.Fatal("InitializeParams is nil")
707707
}
708708

709-
var gotRootsV2 *RootsCapabilities
709+
var gotRootsV2 *RootCapabilities
710710
if params.Capabilities != nil {
711711
gotRootsV2 = params.Capabilities.RootsV2
712712
}

0 commit comments

Comments
 (0)