pub struct McpClient { /* private fields */ }Expand description
MCP 客户端
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub async fn connect(
server_name: impl Into<String>,
config: TransportConfig,
) -> Result<Self>
pub async fn connect( server_name: impl Into<String>, config: TransportConfig, ) -> Result<Self>
创建并初始化 MCP 客户端
Sourcepub fn server_name(&self) -> &str
pub fn server_name(&self) -> &str
获取服务器名称
Sourcepub async fn is_initialized(&self) -> bool
pub async fn is_initialized(&self) -> bool
是否已初始化
Sourcepub async fn capabilities(&self) -> Option<ServerCapabilities>
pub async fn capabilities(&self) -> Option<ServerCapabilities>
获取服务器能力
Sourcepub async fn server_info(&self) -> Option<Implementation>
pub async fn server_info(&self) -> Option<Implementation>
获取服务器信息
Sourcepub async fn list_tools(&self) -> Result<Vec<Tool>>
pub async fn list_tools(&self) -> Result<Vec<Tool>>
列出所有工具
Sourcepub async fn cached_tools(&self) -> Vec<Tool>
pub async fn cached_tools(&self) -> Vec<Tool>
获取缓存的工具列表
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: Option<Value>,
) -> Result<CallToolResult>
pub async fn call_tool( &self, name: &str, arguments: Option<Value>, ) -> Result<CallToolResult>
调用工具
Sourcepub async fn supports_tools(&self) -> bool
pub async fn supports_tools(&self) -> bool
检查服务器是否支持工具
Sourcepub async fn list_resources(&self) -> Result<Vec<Resource>>
pub async fn list_resources(&self) -> Result<Vec<Resource>>
列出所有资源
Sourcepub async fn read_resource(&self, uri: &str) -> Result<Value>
pub async fn read_resource(&self, uri: &str) -> Result<Value>
读取资源
Sourcepub async fn supports_resources(&self) -> bool
pub async fn supports_resources(&self) -> bool
检查服务器是否支持资源
Sourcepub async fn list_prompts(&self) -> Result<Vec<Prompt>>
pub async fn list_prompts(&self) -> Result<Vec<Prompt>>
列出所有 prompt
Sourcepub async fn get_prompt(
&self,
name: &str,
arguments: Option<HashMap<String, String>>,
) -> Result<Value>
pub async fn get_prompt( &self, name: &str, arguments: Option<HashMap<String, String>>, ) -> Result<Value>
获取 prompt
Sourcepub async fn supports_prompts(&self) -> bool
pub async fn supports_prompts(&self) -> bool
检查服务器是否支持 prompt
Sourcepub async fn set_logging_level(&self, level: LogLevel) -> Result<()>
pub async fn set_logging_level(&self, level: LogLevel) -> Result<()>
设置日志级别
Auto Trait Implementations§
impl !Freeze for McpClient
impl !RefUnwindSafe for McpClient
impl Send for McpClient
impl Sync for McpClient
impl Unpin for McpClient
impl UnsafeUnpin for McpClient
impl !UnwindSafe for McpClient
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