pub struct HttpBridge<U, C> { /* private fields */ }Expand description
A bridge served over Streamable HTTP.
Implementations§
Source§impl<U, C> HttpBridge<U, C>
impl<U, C> HttpBridge<U, C>
Sourcepub fn new(
config: ServerConfig,
sessions: Arc<SessionStore<BridgeSession>>,
upstream: U,
identity: Identity,
policy: DegradePolicy,
codec: C,
) -> Result<Self, BridgeServeError>
pub fn new( config: ServerConfig, sessions: Arc<SessionStore<BridgeSession>>, upstream: U, identity: Identity, policy: DegradePolicy, codec: C, ) -> Result<Self, BridgeServeError>
A bridge that opens upstream once per client.
§Errors
DownstreamError::UnnegotiableVersion if the build speaks no
revision a client could negotiate. That list is a build-time constant
and the specification has defined at least one since 2024, so it is a
formality — but a caller building this at startup deserves a real error
rather than a panic later.
Sourcepub fn into_router(self) -> Result<Router, RouterError>
pub fn into_router(self) -> Result<Router, RouterError>
The router, for a caller that wants to serve it itself.
§Errors
RouterError
— a configured security header that is not a legal HTTP value, or
the issue #11 fail-open combination of a wired authenticator and
the default AuthPolicy::Public policy. The same errors the MCP
server’s own builder reports, surfaced through
BridgeServeError::Router on the bind path.
Sourcepub async fn bind(
self,
addr: SocketAddr,
) -> Result<(Bound, SocketAddr), BridgeServeError>
pub async fn bind( self, addr: SocketAddr, ) -> Result<(Bound, SocketAddr), BridgeServeError>
Binds the address and reports what it got, without serving.
Split from serving for the same reason
HttpBuilder
splits it: a caller that passed port 0 has to learn the real address,
and has to learn it before the accept loop starts rather than after.
§Errors
BridgeServeError::Bind when the address is taken or unusable, and
BridgeServeError::Router for an illegal configured header.
Sourcepub async fn serve(
self,
addr: SocketAddr,
) -> Result<SocketAddr, BridgeServeError>
pub async fn serve( self, addr: SocketAddr, ) -> Result<SocketAddr, BridgeServeError>
Binds the address and serves until the accept loop fails.
The one-call path, for a caller that already knows its address.
§Errors
As HttpBridge::bind, and whatever the accept loop itself reported.