MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / shouldSendListChangedNotification

Method shouldSendListChangedNotification

mcp/client.go:450–469  ·  view source on GitHub ↗

shouldSendListChangedNotification checks if the client's capabilities allow sending the given list-changed notification.

(notification string)

Source from the content-addressed store, hash-verified

448// shouldSendListChangedNotification checks if the client's capabilities allow
449// sending the given list-changed notification.
450func (c *Client) shouldSendListChangedNotification(notification string) bool {
451 // Get effective capabilities (considering user-provided defaults).
452 caps := c.opts.Capabilities
453
454 switch notification {
455 case notificationRootsListChanged:
456 // If user didn't specify capabilities, default behavior sends notifications.
457 if caps == nil {
458 return true
459 }
460 // Check RootsV2 first (preferred), then fall back to Roots.
461 if caps.RootsV2 != nil {
462 return caps.RootsV2.ListChanged
463 }
464 return caps.Roots.ListChanged
465 default:
466 // Unknown notification, allow by default.
467 return true
468 }
469}
470
471func (c *Client) listRoots(_ context.Context, req *ListRootsRequest) (*ListRootsResult, error) {
472 c.mu.Lock()

Callers 1

changeAndNotifyFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected