Notifications enable real-time, one-way communication between clients and servers. They’re used to signal events, state changes, and updates without requiring a response, making them perfect for keeping your application synchronized with server state.Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
Understanding Notifications
MCP notifications are JSON-RPC messages without response requirements. They enable:- Real-time updates: Get notified when server state changes
- List synchronization: Tools, resources, and prompts list updates
- Custom events: Server-specific notifications for your application
- Progress tracking: Monitor long-running operations
Bidirectional: Both clients and servers can send notifications. Servers notify clients of changes, while clients notify servers of environment changes like root directories.
Notification Flow
Server → Client: Event notifications (tool lists changed, progress updates, custom events) Client → Server: Environment notifications (roots changed, configuration updates)Receiving Notifications (Server → Client)
You can set a defaultonNotification handler at the client level (root config or the second argument to new MCPClient(config, options)); all servers will use it unless they override it. You can also register a notification handler per session using the on method:
Notification Structure
Notifications follow the JSON-RPC 2.0 format without anid field:
Standard MCP Notifications
MCP defines several standard notification types that servers may send:Tools List Changed
Sent when the server’s available tools have changed:Resources List Changed
Sent when resources have been added, removed, or modified:Prompts List Changed
Sent when prompts have changed:Custom Notifications
Servers can send custom notifications with any method name:Sending Notifications (Client → Server)
Roots Changed
Roots represent directories or files that the client has access to. When you update roots, the client automatically sends anotifications/roots/list_changed notification to the server:
Initial Roots at Connection
You can provide initial roots when creating the connector:TypeScript Types
Import theNotification type for type-safe handlers:
Root Type
Requirements
Notifications require:- Stateful Connection: The server must maintain sessions (stateful mode)
- Active Session: The client must have an active, initialized session
- Streaming Transport: Either SSE or Streamable HTTP transport
Notifications don’t work in stateless edge environments where sessions aren’t maintained between requests.
Next Steps
- Server Notifications - Learn how servers send notifications
- Client Configuration - Understand connection types and transport options
- Resources - Handle resource change notifications
- Tools - Handle tool list change notifications