Skip to main content

HttpMCPClient

Struct HttpMCPClient 

Source
pub struct HttpMCPClient { /* private fields */ }
Expand description

HTTP MCP客户端 / HTTP MCP client

Implementations§

Source§

impl HttpMCPClient

Source

pub fn new(params: HttpServerParameters) -> Self

创建新的HTTP客户端 / Create new HTTP client

Source

pub async fn is_subscribed(&self, uri: &str) -> bool

检查是否已订阅指定资源

Source

pub async fn get_subscriptions(&self) -> Vec<String>

获取所有订阅的 URI 列表

Source

pub async fn subscription_count(&self) -> usize

获取订阅数量

Source

pub async fn get_cached_resource(&self, uri: &str) -> Option<Value>

获取缓存的资源数据

Source

pub async fn has_cache(&self, uri: &str) -> bool

检查是否有缓存

Source

pub async fn cache_size(&self) -> usize

获取缓存大小

Source

pub async fn cleanup_cache(&self) -> usize

清理过期缓存

Source

pub async fn cache_keys(&self) -> Vec<String>

获取所有缓存的 URI 列表

Source

pub async fn clear_cache(&self)

清空所有缓存

Trait Implementations§

Source§

impl Debug for HttpMCPClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MCPClientProtocol for HttpMCPClient

Source§

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,

连接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,

断开连接 / 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,

获取可用工具列表 / 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,

调用工具 / 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,

列出窗口资源 / 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,

获取窗口详情 / 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,

订阅窗口资源更新 / 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,

取消订阅窗口资源更新 / 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,

执行健康检查 / Perform health check 默认实现通过检查状态和尝试 list_tools 来验证连接 Default implementation checks state and tries list_tools to verify connection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more