pub struct McpServer { /* private fields */ }Expand description
MCP server that dispatches JSON-RPC requests to the appropriate handler
Owns the shared state and tool registry. Transport layers feed parsed
requests into handle_request and send the returned responses.
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub const fn new(state: SharedState, tools: ToolRegistry) -> Self
pub const fn new(state: SharedState, tools: ToolRegistry) -> Self
Create a server with the given shared state and tool registry
Sourcepub async fn handle_request(
&self,
request: JsonRpcRequest,
) -> Option<JsonRpcResponse>
pub async fn handle_request( &self, request: JsonRpcRequest, ) -> Option<JsonRpcResponse>
Route a JSON-RPC request to the appropriate MCP handler
Returns None for notifications (requests without an id).
Auto Trait Implementations§
impl Freeze for McpServer
impl !RefUnwindSafe for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl UnsafeUnpin for McpServer
impl !UnwindSafe for McpServer
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 more