pub struct McpClient<T: McpTransport> { /* private fields */ }Expand description
MCP Client for communicating with MCP servers
Implementations§
Source§impl<T: McpTransport> McpClient<T>
impl<T: McpTransport> McpClient<T>
Sourcepub async fn new(transport: T) -> Result<Self, McpError>
pub async fn new(transport: T) -> Result<Self, McpError>
Create a new MCP client and initialize the connection
Sourcepub fn new_uninit(transport: T) -> Self
pub fn new_uninit(transport: T) -> Self
Create without auto-initialization (for testing)
Sourcepub fn server_info(&self) -> Option<&Implementation>
pub fn server_info(&self) -> Option<&Implementation>
Get server info
Sourcepub fn capabilities(&self) -> Option<&ServerCapabilities>
pub fn capabilities(&self) -> Option<&ServerCapabilities>
Get server capabilities
Sourcepub fn supports_tools(&self) -> bool
pub fn supports_tools(&self) -> bool
Check if server supports tools
Sourcepub fn supports_resources(&self) -> bool
pub fn supports_resources(&self) -> bool
Check if server supports resources
Sourcepub fn supports_prompts(&self) -> bool
pub fn supports_prompts(&self) -> bool
Check if server supports prompts
Sourcepub async fn get_tools(&mut self) -> Result<&[McpTool], McpError>
pub async fn get_tools(&mut self) -> Result<&[McpTool], McpError>
Get cached tools (or fetch if not cached)
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: Value,
) -> Result<CallToolResult, McpError>
pub async fn call_tool( &self, name: &str, arguments: Value, ) -> Result<CallToolResult, McpError>
Call a tool
Sourcepub async fn list_resources(&self) -> Result<Vec<McpResource>, McpError>
pub async fn list_resources(&self) -> Result<Vec<McpResource>, McpError>
List available resources
Sourcepub async fn read_resource(
&self,
uri: &str,
) -> Result<ResourceContent, McpError>
pub async fn read_resource( &self, uri: &str, ) -> Result<ResourceContent, McpError>
Read a resource
Auto Trait Implementations§
impl<T> Freeze for McpClient<T>
impl<T> RefUnwindSafe for McpClient<T>where
T: RefUnwindSafe,
impl<T> Send for McpClient<T>
impl<T> Sync for McpClient<T>
impl<T> Unpin for McpClient<T>
impl<T> UnsafeUnpin for McpClient<T>
impl<T> UnwindSafe for McpClient<T>where
T: RefUnwindSafe,
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