mcp: fix broken client root capabilities (#698)

To address #607, add ClientCapabilities.RootsV2, and populate it when
constructing sending and receiving InitializeParams.

Fixes #607
This commit is contained in:
Robert Findley 2025-12-11 10:16:56 -05:00 • committed by GitHub
commit a5e369ed12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -131,7 +131,11 @@ type ClientSessionOptions struct {
func (c *Client) capabilities() *ClientCapabilities {
caps := &ClientCapabilities{}
// Due to an oversight (#607), roots require special handling.
caps.Roots.ListChanged = true
caps.RootsV2 = &RootCapabilities{
ListChanged: true,
}
if c.opts.CreateMessageHandler != nil {
caps.Sampling = &SamplingCapabilities{}
}