Receive server notifications
Set a default handler on the client:onNotification
callback. Per-server callbacks take precedence over the global default.
You can also register a handler on a connection:
notifications/tools/list_changednotifications/resources/list_changednotifications/prompts/list_changed
React
Each server managed byMcpClientProvider exposes:
notifications, the stored notification entriesunreadNotificationCountmarkNotificationRead,markAllNotificationsRead, andclearNotifications
onNotificationReceived on a server configuration to run custom logic when
the provider receives and stores a notification.
Roots compatibility
setRoots() and getRoots() are compatibility APIs for sessionful servers.
Roots are not part of the current sessionless protocol.
For a compatible server, pass initial roots in its client configuration:
connection.setRoots(roots) replaces the cached roots and sends
notifications/roots/list_changed when connected. connection.getRoots()
returns the current cached list. Use these methods only for a server that
negotiated the sessionful protocol and requests roots.