pub struct HttpTransport { /* private fields */ }Available on crate feature
mcp only.Expand description
HTTP 传输层(MCP Streamable HTTP)
通过 HTTP POST 发送 JSON-RPC 请求,适用于远程 MCP 服务端。 符合 MCP Streamable HTTP 规范:直接 POST 到端点 URL。
支持异步响应:当服务端返回 202 Accepted 时, 通过通知通道等待实际响应。
Implementations§
Source§impl HttpTransport
impl HttpTransport
Trait Implementations§
Source§impl McpTransport for HttpTransport
impl McpTransport for HttpTransport
Source§fn send(
&self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = Result<JsonRpcResponse, ReactError>> + Send + '_>>
fn send( &self, request: JsonRpcRequest, ) -> Pin<Box<dyn Future<Output = Result<JsonRpcResponse, ReactError>> + Send + '_>>
发送请求并等待响应(传输层自动管理请求 ID)
Source§fn notify(
&self,
notification: JsonRpcNotification,
) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + '_>>
fn notify( &self, notification: JsonRpcNotification, ) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + '_>>
发送通知(无需等待响应)
Source§fn notification_rx(&self) -> Option<Arc<dyn JsonRpcNotificationReceiver>>
fn notification_rx(&self) -> Option<Arc<dyn JsonRpcNotificationReceiver>>
获取通知接收通道(用于接收服务端推送的通知)
返回 None 表示该传输层不支持通知接收
Auto Trait Implementations§
impl Freeze for HttpTransport
impl !RefUnwindSafe for HttpTransport
impl Send for HttpTransport
impl Sync for HttpTransport
impl Unpin for HttpTransport
impl UnsafeUnpin for HttpTransport
impl !UnwindSafe for HttpTransport
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request