Skip to main content

serve_with

Function serve_with 

Source
pub async fn serve_with<T, E, A>(
    transport: T,
    sink: impl Fn(McpCommand) -> bool + Send + 'static,
) -> Result<RunningService<RoleServer, McpServer>, Box<ServerInitializeError>>
where T: IntoTransport<RoleServer, E, A>, E: Error + Send + Sync + 'static,
Available on crate feature mcp and non-WebAssembly only.
Expand description

Serve MCP over any transport, handing every command to sink.

The transport is whatever rmcp accepts - stdio, or a pair of streams for a test that wants the server in its own process. The returned service is running; await waiting to serve until the peer leaves.

ยงErrors

Fails when the service cannot complete its handshake over transport.