pub struct McpDispatcher { /* private fields */ }Expand description
Advanced MCP request dispatcher with routing, middleware, and error handling
Implementations§
Source§impl McpDispatcher
impl McpDispatcher
pub fn new() -> Self
Sourcepub fn register_exact_handler(
self,
method: String,
handler: Arc<dyn McpHandler>,
) -> Self
pub fn register_exact_handler( self, method: String, handler: Arc<dyn McpHandler>, ) -> Self
Register a handler for exact method matching
Sourcepub fn register_pattern_handler(
self,
pattern: String,
handler: Arc<dyn McpHandler>,
) -> Self
pub fn register_pattern_handler( self, pattern: String, handler: Arc<dyn McpHandler>, ) -> Self
Register a handler for pattern matching (e.g., “tools/*”)
Sourcepub fn register_middleware(
self,
middleware: Arc<dyn DispatchMiddleware>,
) -> Self
pub fn register_middleware( self, middleware: Arc<dyn DispatchMiddleware>, ) -> Self
Register middleware
Sourcepub fn set_default_handler(self, handler: Arc<dyn McpHandler>) -> Self
pub fn set_default_handler(self, handler: Arc<dyn McpHandler>) -> Self
Set default fallback handler
Sourcepub async fn dispatch(
&self,
method: &str,
params: Option<Value>,
session: Option<SessionContext>,
) -> McpResult<Value>
pub async fn dispatch( &self, method: &str, params: Option<Value>, session: Option<SessionContext>, ) -> McpResult<Value>
Dispatch a request through the routing and middleware pipeline
Sourcepub fn get_supported_methods(&self) -> Vec<String>
pub fn get_supported_methods(&self) -> Vec<String>
Get all registered methods and patterns
Trait Implementations§
Auto Trait Implementations§
impl Freeze for McpDispatcher
impl !RefUnwindSafe for McpDispatcher
impl Send for McpDispatcher
impl Sync for McpDispatcher
impl Unpin for McpDispatcher
impl !UnwindSafe for McpDispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.