pub struct McpDispatcher { /* private fields */ }Expand description
Transport-agnostic MCP dispatcher used by the v0.10.2 HTTP /mcp
route. Holds the per-tenant SoloMcpServer needed to answer
tools/list and tools/call.
The dispatcher itself is stateless beyond the held server — callers
build a fresh dispatcher per request (cheap; the server is
Arc-cloneable) and discard it after dispatch returns.
Implementations§
Source§impl McpDispatcher
impl McpDispatcher
Sourcepub fn new(
registry: Arc<TenantRegistry>,
tenant: Arc<TenantHandle>,
user_aliases: Vec<String>,
audit_principal: Option<String>,
) -> Self
pub fn new( registry: Arc<TenantRegistry>, tenant: Arc<TenantHandle>, user_aliases: Vec<String>, audit_principal: Option<String>, ) -> Self
Build a dispatcher for one tenant. The caller is expected to
resolve the tenant (via X-Solo-Tenant header for HTTP, or via
--tenant flag for stdio) and pass an Arc<TenantHandle> here.
audit_principal is the subject that authored every tool call
dispatched through this server — typically "bearer" for
bearer-authenticated HTTP requests, the SOLO_MCP_PRINCIPAL_TOKEN
env-var value for stdio, or None for unauthenticated loopback.
Sourcepub fn from_server(server: SoloMcpServer) -> Self
pub fn from_server(server: SoloMcpServer) -> Self
Wrap an already-built SoloMcpServer. Used by tests that want
to pin the underlying server’s principal exactly; production
callers should prefer Self::new.
Sourcepub async fn dispatch(
&self,
request: JsonRpcRequest,
session: Option<Arc<SessionState>>,
) -> Option<JsonRpcResponse>
pub async fn dispatch( &self, request: JsonRpcRequest, session: Option<Arc<SessionState>>, ) -> Option<JsonRpcResponse>
Dispatch one JSON-RPC request and return the wire response.
Returns None when the input is a notification (no id field) —
per JSON-RPC 2.0 the server MUST NOT respond to notifications.
The HTTP transport translates None into a 204 No Content or
empty 200, depending on the client; the stdio path doesn’t use
this method (rmcp handles framing for stdio).
v0.11.0 P3: session is the Arc<SessionState> planted on
/mcp requests by the session middleware (Some on HTTP transport,
None on stdio). When the request is a tools/call carrying
_meta.progressToken AND session is Some, the handler builds
a ProgressReporter and threads it into SoloMcpServer::dispatch_tool.
Other request types ignore the session argument entirely.
Trait Implementations§
Source§impl Clone for McpDispatcher
impl Clone for McpDispatcher
Source§fn clone(&self) -> McpDispatcher
fn clone(&self) -> McpDispatcher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for McpDispatcher
impl !RefUnwindSafe for McpDispatcher
impl Send for McpDispatcher
impl Sync for McpDispatcher
impl Unpin for McpDispatcher
impl UnsafeUnpin 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
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> 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>
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>
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