fastmcp.client.messages

Classes

MessageHandler

This class is used to handle MCP messages sent to the client. It is used to handle all messages, requests, notifications, and exceptions. Users can override any of the hooks Methods:

dispatch

dispatch(self, message: Message) -> None

on_message

on_message(self, message: Message) -> None

on_request

on_request(self, message: RequestResponder[mcp.types.ServerRequest, mcp.types.ClientResult]) -> None

on_ping

on_ping(self, message: mcp.types.PingRequest) -> None

on_list_roots

on_list_roots(self, message: mcp.types.ListRootsRequest) -> None

on_create_message

on_create_message(self, message: mcp.types.CreateMessageRequest) -> None

on_notification

on_notification(self, message: mcp.types.ServerNotification) -> None

on_exception

on_exception(self, message: Exception) -> None

on_progress

on_progress(self, message: mcp.types.ProgressNotification) -> None

on_logging_message

on_logging_message(self, message: mcp.types.LoggingMessageNotification) -> None

on_tool_list_changed

on_tool_list_changed(self, message: mcp.types.ToolListChangedNotification) -> None

on_resource_list_changed

on_resource_list_changed(self, message: mcp.types.ResourceListChangedNotification) -> None

on_prompt_list_changed

on_prompt_list_changed(self, message: mcp.types.PromptListChangedNotification) -> None

on_resource_updated

on_resource_updated(self, message: mcp.types.ResourceUpdatedNotification) -> None

on_cancelled

on_cancelled(self, message: mcp.types.CancelledNotification) -> None