Handle MCP messages, requests, and notifications with custom message handlers.
New in version: 2.9.1
MCP clients can receive various types of messages from servers, including requests that need responses and notifications that don’t. The message handler provides a unified way to process all these messages.
MessageHandler
class you can subclass to take advantage of specific hooks:
sampling_handler
progress_handler
log_handler