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

Method ResourceUpdated

mcp/server.go:882–890  ·  view source on GitHub ↗

ResourceUpdated sends a notification to all clients that have subscribed to the resource specified in params. This method is the primary way for a server author to signal that a resource has changed.

(ctx context.Context, params *ResourceUpdatedNotificationParams)

Source from the content-addressed store, hash-verified

880// resource specified in params. This method is the primary way for a
881// server author to signal that a resource has changed.
882func (s *Server) ResourceUpdated(ctx context.Context, params *ResourceUpdatedNotificationParams) error {
883 s.mu.Lock()
884 subscribedSessions := s.resourceSubscriptions[params.URI]
885 sessions := slices.Collect(maps.Keys(subscribedSessions))
886 s.mu.Unlock()
887 notifySessions(sessions, notificationResourceUpdated, params, s.opts.Logger)
888 s.opts.Logger.Info("resource updated notification sent", "uri", params.URI, "subscriber_count", len(sessions))
889 return nil
890}
891
892func (s *Server) subscribe(ctx context.Context, req *SubscribeRequest) (*emptyResult, error) {
893 if s.opts.SubscribeHandler == nil {

Callers 2

TestEndToEndFunction · 0.95
watchedResourceUpdaterFunction · 0.80

Calls 1

notifySessionsFunction · 0.85

Tested by 1

TestEndToEndFunction · 0.76