pub struct McpClient { /* private fields */ }Expand description
Main MCP client
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub fn new(transport: BoxedTransport, config: ClientConfig) -> Self
pub fn new(transport: BoxedTransport, config: ClientConfig) -> Self
Create a new MCP client with the given transport
Sourcepub async fn connect(&self) -> McpClientResult<()>
pub async fn connect(&self) -> McpClientResult<()>
Connect to the MCP server
Sourcepub async fn disconnect(&self) -> McpClientResult<()>
pub async fn disconnect(&self) -> McpClientResult<()>
Disconnect from the MCP server
Sourcepub async fn connection_status(&self) -> ConnectionStatus
pub async fn connection_status(&self) -> ConnectionStatus
Get client connection status
Sourcepub async fn list_tools(&self) -> McpClientResult<Vec<Tool>>
pub async fn list_tools(&self) -> McpClientResult<Vec<Tool>>
List available tools
Sourcepub async fn list_tools_paginated(
&self,
cursor: Option<Cursor>,
) -> McpClientResult<ListToolsResult>
pub async fn list_tools_paginated( &self, cursor: Option<Cursor>, ) -> McpClientResult<ListToolsResult>
List available tools with pagination support
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: Value,
) -> McpClientResult<Vec<ToolResult>>
pub async fn call_tool( &self, name: &str, arguments: Value, ) -> McpClientResult<Vec<ToolResult>>
Call a tool
Sourcepub async fn list_resources(&self) -> McpClientResult<Vec<Resource>>
pub async fn list_resources(&self) -> McpClientResult<Vec<Resource>>
List available resources
Sourcepub async fn list_resources_paginated(
&self,
cursor: Option<Cursor>,
) -> McpClientResult<ListResourcesResult>
pub async fn list_resources_paginated( &self, cursor: Option<Cursor>, ) -> McpClientResult<ListResourcesResult>
List available resources with pagination support
Sourcepub async fn read_resource(
&self,
uri: &str,
) -> McpClientResult<Vec<ResourceContent>>
pub async fn read_resource( &self, uri: &str, ) -> McpClientResult<Vec<ResourceContent>>
Read a resource
Sourcepub async fn list_prompts(&self) -> McpClientResult<Vec<Prompt>>
pub async fn list_prompts(&self) -> McpClientResult<Vec<Prompt>>
List available prompts
Sourcepub async fn list_prompts_paginated(
&self,
cursor: Option<Cursor>,
) -> McpClientResult<ListPromptsResult>
pub async fn list_prompts_paginated( &self, cursor: Option<Cursor>, ) -> McpClientResult<ListPromptsResult>
List available prompts with pagination support
Sourcepub async fn get_prompt(
&self,
name: &str,
arguments: Option<Value>,
) -> McpClientResult<Vec<PromptMessage>>
pub async fn get_prompt( &self, name: &str, arguments: Option<Value>, ) -> McpClientResult<Vec<PromptMessage>>
Get a prompt
Sourcepub async fn ping(&self) -> McpClientResult<()>
pub async fn ping(&self) -> McpClientResult<()>
Send a ping to test connectivity
Sourcepub async fn stream_handler(&self) -> MutexGuard<'_, StreamHandler>
pub async fn stream_handler(&self) -> MutexGuard<'_, StreamHandler>
Get stream handler for event callbacks
Sourcepub async fn session_info(&self) -> SessionInfo
pub async fn session_info(&self) -> SessionInfo
Get session information
Sourcepub async fn transport_stats(&self) -> TransportStatistics
pub async fn transport_stats(&self) -> TransportStatistics
Get transport statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for McpClient
impl !RefUnwindSafe for McpClient
impl Send for McpClient
impl Sync for McpClient
impl Unpin 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