pub struct MiddlewareStack<H: McpHandler> { /* private fields */ }Expand description
A handler wrapped with a middleware stack.
This implements McpHandler and runs requests through the middleware chain.
Implementations§
Source§impl<H: McpHandler> MiddlewareStack<H>
impl<H: McpHandler> MiddlewareStack<H>
Sourcepub fn with_middleware<M: McpMiddleware>(self, middleware: M) -> Self
pub fn with_middleware<M: McpMiddleware>(self, middleware: M) -> Self
Add a middleware to the stack.
Middlewares are called in the order they are added.
Sourcepub fn middleware_count(&self) -> usize
pub fn middleware_count(&self) -> usize
Get the number of middlewares in the stack.
Trait Implementations§
Source§impl<H: McpHandler> Clone for MiddlewareStack<H>
impl<H: McpHandler> Clone for MiddlewareStack<H>
Source§impl<H: McpHandler> Debug for MiddlewareStack<H>
impl<H: McpHandler> Debug for MiddlewareStack<H>
Source§impl<H: McpHandler> McpHandler for MiddlewareStack<H>
impl<H: McpHandler> McpHandler for MiddlewareStack<H>
Source§fn server_info(&self) -> ServerInfo
fn server_info(&self) -> ServerInfo
Returns server information (name, version, description, etc.) Read more
Source§fn call_tool<'a>(
&'a self,
name: &'a str,
args: Value,
ctx: &'a RequestContext,
) -> impl Future<Output = McpResult<ToolResult>> + MaybeSend + 'a
fn call_tool<'a>( &'a self, name: &'a str, args: Value, ctx: &'a RequestContext, ) -> impl Future<Output = McpResult<ToolResult>> + MaybeSend + 'a
Calls a tool by name with the given arguments. Read more
Source§fn read_resource<'a>(
&'a self,
uri: &'a str,
ctx: &'a RequestContext,
) -> impl Future<Output = McpResult<ResourceResult>> + MaybeSend + 'a
fn read_resource<'a>( &'a self, uri: &'a str, ctx: &'a RequestContext, ) -> impl Future<Output = McpResult<ResourceResult>> + MaybeSend + 'a
Reads a resource by URI. Read more
Source§fn get_prompt<'a>(
&'a self,
name: &'a str,
args: Option<Value>,
ctx: &'a RequestContext,
) -> impl Future<Output = McpResult<PromptResult>> + MaybeSend + 'a
fn get_prompt<'a>( &'a self, name: &'a str, args: Option<Value>, ctx: &'a RequestContext, ) -> impl Future<Output = McpResult<PromptResult>> + MaybeSend + 'a
Gets a prompt by name with optional arguments. Read more
Source§fn on_initialize(&self) -> impl Future<Output = McpResult<()>> + MaybeSend
fn on_initialize(&self) -> impl Future<Output = McpResult<()>> + MaybeSend
Called when the server is initialized. Read more
Source§fn on_shutdown(&self) -> impl Future<Output = McpResult<()>> + MaybeSend
fn on_shutdown(&self) -> impl Future<Output = McpResult<()>> + MaybeSend
Called when the server is shutting down. Read more
Source§fn list_tasks<'a>(
&'a self,
_cursor: Option<&'a str>,
_limit: Option<usize>,
_ctx: &'a RequestContext,
) -> impl Future<Output = Result<ListTasksResult, McpError>> + MaybeSend + 'a
fn list_tasks<'a>( &'a self, _cursor: Option<&'a str>, _limit: Option<usize>, _ctx: &'a RequestContext, ) -> impl Future<Output = Result<ListTasksResult, McpError>> + MaybeSend + 'a
Lists all active and recent tasks. Read more
Source§fn get_task<'a>(
&'a self,
_task_id: &'a str,
_ctx: &'a RequestContext,
) -> impl Future<Output = Result<Task, McpError>> + MaybeSend + 'a
fn get_task<'a>( &'a self, _task_id: &'a str, _ctx: &'a RequestContext, ) -> impl Future<Output = Result<Task, McpError>> + MaybeSend + 'a
Gets the current state of a specific task. Read more
Auto Trait Implementations§
impl<H> Freeze for MiddlewareStack<H>
impl<H> !RefUnwindSafe for MiddlewareStack<H>
impl<H> Send for MiddlewareStack<H>
impl<H> Sync for MiddlewareStack<H>
impl<H> Unpin for MiddlewareStack<H>
impl<H> UnsafeUnpin for MiddlewareStack<H>
impl<H> !UnwindSafe for MiddlewareStack<H>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> McpHandlerExt for Twhere
T: McpHandler,
impl<T> McpHandlerExt for Twhere
T: McpHandler,
Source§impl<T> McpServerExt for Twhere
T: McpHandler,
impl<T> McpServerExt for Twhere
T: McpHandler,
Source§fn builder(self) -> ServerBuilder<Self>
fn builder(self) -> ServerBuilder<Self>
Create a server builder for this handler. Read more