Skip to main content
MCP notifications are one-way JSON-RPC messages with no response. Register a handler when your application needs to react to server updates.

Receive server notifications

Set a default handler on the client:
An individual server configuration can provide its own onNotification callback. Per-server callbacks take precedence over the global default. You can also register a handler on a connection:
The standard list-change method names are:
  • notifications/tools/list_changed
  • notifications/resources/list_changed
  • notifications/prompts/list_changed
The client automatically refreshes its tool cache for tool list changes. Refresh resources or prompts when your application needs their updated values.

React

Each server managed by McpClientProvider exposes:
  • notifications, the stored notification entries
  • unreadNotificationCount
  • markNotificationRead, markAllNotificationsRead, and clearNotifications
Set 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:
Calling 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. Server-side notification sending is covered in Notifications.