pub trait MCPClientProtocol: Send + Sync {
// Required methods
fn state(&self) -> ClientState;
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 disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), 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;
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 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 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 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 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;
// Provided method
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthCheckResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
MCP客户端协议trait / MCP client protocol trait
Required Methods§
Sourcefn state(&self) -> ClientState
fn state(&self) -> ClientState
获取客户端状态 / Get client state
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Provided Methods§
Sourcefn 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