Skip to main content
Version: 1.1.0

ClientHandlerCore Trait

ClientHandlerCore gives you full control over every JSON-RPC message:

#[async_trait]
pub trait ClientHandlerCore: Send + Sync + 'static {
async fn handle_request(
&self, request: ServerJsonrpcRequest, runtime: &dyn McpClient,
) -> Result<ResultFromClient, RpcError>;

async fn handle_notification(
&self, notification: NotificationFromServer, runtime: &dyn McpClient,
) -> Result<(), RpcError>;

async fn handle_error(
&self, error: &RpcError, runtime: &dyn McpClient,
) -> Result<(), RpcError>;
}

Use .to_mcp_client_handler() (shared by both conversion traits) and client_runtime_core::create_client().