pub struct HttpMCPClient { /* private fields */ }Expand description
HTTP MCP客户端 / HTTP MCP client
Implementations§
Source§impl HttpMCPClient
impl HttpMCPClient
Sourcepub fn new(params: HttpServerParameters) -> Self
pub fn new(params: HttpServerParameters) -> Self
创建新的HTTP客户端 / Create new HTTP client
Sourcepub async fn is_subscribed(&self, uri: &str) -> bool
pub async fn is_subscribed(&self, uri: &str) -> bool
检查是否已订阅指定资源
Sourcepub async fn get_subscriptions(&self) -> Vec<String>
pub async fn get_subscriptions(&self) -> Vec<String>
获取所有订阅的 URI 列表
Sourcepub async fn subscription_count(&self) -> usize
pub async fn subscription_count(&self) -> usize
获取订阅数量
Sourcepub async fn get_cached_resource(&self, uri: &str) -> Option<Value>
pub async fn get_cached_resource(&self, uri: &str) -> Option<Value>
获取缓存的资源数据
Sourcepub async fn cache_size(&self) -> usize
pub async fn cache_size(&self) -> usize
获取缓存大小
Sourcepub async fn cleanup_cache(&self) -> usize
pub async fn cleanup_cache(&self) -> usize
清理过期缓存
Sourcepub async fn cache_keys(&self) -> Vec<String>
pub async fn cache_keys(&self) -> Vec<String>
获取所有缓存的 URI 列表
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
清空所有缓存
Trait Implementations§
Source§impl Debug for HttpMCPClient
impl Debug for HttpMCPClient
Source§impl MCPClientProtocol for HttpMCPClient
impl MCPClientProtocol for HttpMCPClient
Source§fn state(&self) -> ClientState
fn state(&self) -> ClientState
获取客户端状态 / Get client state
Source§fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
连接MCP服务器 / Connect to MCP server
Source§fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
断开连接 / Disconnect
Source§fn list_tools<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Tool>, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_tools<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Tool>, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取可用工具列表 / Get available tools list
Source§fn call_tool<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<CallToolResult, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_tool<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<CallToolResult, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
调用工具 / Call tool
Source§fn list_windows<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Resource>, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_windows<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Resource>, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
列出窗口资源 / List window resources
Source§fn get_window_detail<'life0, 'async_trait>(
&'life0 self,
resource: Resource,
) -> Pin<Box<dyn Future<Output = Result<ReadResourceResult, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_window_detail<'life0, 'async_trait>(
&'life0 self,
resource: Resource,
) -> Pin<Box<dyn Future<Output = Result<ReadResourceResult, MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取窗口详情 / Get window detail
Source§fn subscribe_window<'life0, 'async_trait>(
&'life0 self,
resource: Resource,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_window<'life0, 'async_trait>(
&'life0 self,
resource: Resource,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
订阅窗口资源更新 / Subscribe to window resource updates
Source§fn unsubscribe_window<'life0, 'async_trait>(
&'life0 self,
resource: Resource,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn unsubscribe_window<'life0, 'async_trait>(
&'life0 self,
resource: Resource,
) -> Pin<Box<dyn Future<Output = Result<(), MCPClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
取消订阅窗口资源更新 / Unsubscribe from window resource updates
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthCheckResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthCheckResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
执行健康检查 / Perform health check
默认实现通过检查状态和尝试 list_tools 来验证连接
Default implementation checks state and tries list_tools to verify connection
Auto Trait Implementations§
impl Freeze for HttpMCPClient
impl !RefUnwindSafe for HttpMCPClient
impl Send for HttpMCPClient
impl Sync for HttpMCPClient
impl Unpin for HttpMCPClient
impl UnsafeUnpin for HttpMCPClient
impl !UnwindSafe for HttpMCPClient
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 moreSource§impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
type Error = <Target as OctetsFrom<Source>>::Error
Source§fn try_octets_into(
self,
) -> Result<Target, <Source as OctetsInto<Target>>::Error>
fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>
Performs the conversion.
Source§fn octets_into(self) -> Target
fn octets_into(self) -> Target
Performs an infallible conversion.