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

Method shouldSendListChangedNotification

mcp/server.go:663–688  ·  view source on GitHub ↗

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

(notification string)

Source from the content-addressed store, hash-verified

661// shouldSendListChangedNotification checks if the server's capabilities allow
662// sending the given list-changed notification.
663func (s *Server) shouldSendListChangedNotification(notification string) bool {
664 // Get effective capabilities (considering user-provided defaults).
665 caps := s.opts.Capabilities
666
667 switch notification {
668 case notificationToolListChanged:
669 // If user didn't specify capabilities, default behavior sends notifications.
670 if caps == nil || caps.Tools == nil {
671 return true
672 }
673 return caps.Tools.ListChanged
674 case notificationPromptListChanged:
675 if caps == nil || caps.Prompts == nil {
676 return true
677 }
678 return caps.Prompts.ListChanged
679 case notificationResourceListChanged:
680 if caps == nil || caps.Resources == nil {
681 return true
682 }
683 return caps.Resources.ListChanged
684 default:
685 // Unknown notification, allow by default.
686 return true
687 }
688}
689
690// Sessions returns an iterator that yields the current set of server sessions.
691//

Callers 1

changeAndNotifyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected