pub struct McpHandlerConfig {
pub sampling: Option<Arc<dyn McpSamplingResponder>>,
pub elicitation: Option<Arc<dyn McpElicitationResponder>>,
pub roots: Option<Arc<dyn McpRootsProvider>>,
pub auth: Option<Arc<dyn McpAuthResponder>>,
pub error_responder: Option<Arc<dyn McpErrorResponder>>,
pub events_capacity: Option<usize>,
}Expand description
Configuration applied to every McpClientHandler this crate builds on
behalf of a connection or McpServerManager.
Holds the optional sampling / elicitation / roots responders plus the
broadcast capacity for McpServerEvent subscribers. Pass an instance to
McpConnection::connect_with_handler to drive a single connection, or
install one on the manager via
McpServerManager::with_handler_config / per-trait builders.
Fields§
§sampling: Option<Arc<dyn McpSamplingResponder>>Responder for server-initiated sampling/createMessage requests.
elicitation: Option<Arc<dyn McpElicitationResponder>>Responder for server-initiated elicitation/create requests.
roots: Option<Arc<dyn McpRootsProvider>>Provider for roots/list.
auth: Option<Arc<dyn McpAuthResponder>>Resolver for auth challenges raised during MCP operations. When
installed, McpToolAdapter::invoke (and other operation paths)
invoke the responder inline on auth challenges and retry — auth
never surfaces as a loop interrupt.
error_responder: Option<Arc<dyn McpErrorResponder>>Handler invoked when an MCP server returns a JSON-RPC error for an
invoked tool. When installed, McpToolAdapter::invoke forwards
the typed McpInvocationError to the responder before falling
back to ToolError::ExecutionFailed; the responder may synthesize
a CallToolResult (the agent sees a successful tool call) or
pass the error through unchanged.
events_capacity: Option<usize>Broadcast capacity for the McpServerEvent channel. Defaults to
DEFAULT_EVENTS_CAPACITY when None.
Implementations§
Source§impl McpHandlerConfig
impl McpHandlerConfig
Sourcepub fn with_sampling_responder(
self,
responder: Arc<dyn McpSamplingResponder>,
) -> Self
pub fn with_sampling_responder( self, responder: Arc<dyn McpSamplingResponder>, ) -> Self
Sets the sampling responder.
Sourcepub fn with_elicitation_responder(
self,
responder: Arc<dyn McpElicitationResponder>,
) -> Self
pub fn with_elicitation_responder( self, responder: Arc<dyn McpElicitationResponder>, ) -> Self
Sets the elicitation responder.
Sourcepub fn with_roots_provider(self, provider: Arc<dyn McpRootsProvider>) -> Self
pub fn with_roots_provider(self, provider: Arc<dyn McpRootsProvider>) -> Self
Sets the roots provider.
Sourcepub fn with_auth_responder(self, responder: Arc<dyn McpAuthResponder>) -> Self
pub fn with_auth_responder(self, responder: Arc<dyn McpAuthResponder>) -> Self
Sets the auth responder.
Sourcepub fn with_error_responder(self, responder: Arc<dyn McpErrorResponder>) -> Self
pub fn with_error_responder(self, responder: Arc<dyn McpErrorResponder>) -> Self
Sets the invocation-error responder.
Sourcepub fn with_events_capacity(self, capacity: usize) -> Self
pub fn with_events_capacity(self, capacity: usize) -> Self
Sets the broadcast capacity for McpServerEvent subscribers.
Sourcepub fn build(&self) -> (McpClientHandler, McpClientChannels)
pub fn build(&self) -> (McpClientHandler, McpClientChannels)
Builds a handler together with a fresh McpClientChannels pair —
the notification receiver and a new broadcast sender for
McpServerEvent.
Sourcepub fn build_with(
&self,
events: Sender<McpServerEvent>,
) -> (McpClientHandler, McpClientChannels)
pub fn build_with( &self, events: Sender<McpServerEvent>, ) -> (McpClientHandler, McpClientChannels)
Builds a handler that publishes McpServerEvent into the provided
broadcast sender. Use this when adopting an externally constructed
rmcp service via McpConnection::from_running_service_with_events
so subscribers see the same stream.
Trait Implementations§
Source§impl Clone for McpHandlerConfig
impl Clone for McpHandlerConfig
Source§fn clone(&self) -> McpHandlerConfig
fn clone(&self) -> McpHandlerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more