pub struct McpClient { /* private fields */ }Available on crate feature
mcp only.Expand description
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub fn new(transport: impl McpTransport + 'static) -> McpClient
pub fn new(transport: impl McpTransport + 'static) -> McpClient
Create a new client with a transport.
Sourcepub async fn stdio(command: &str, args: &[&str]) -> Result<McpClient, McpError>
pub async fn stdio(command: &str, args: &[&str]) -> Result<McpClient, McpError>
Create a client that connects via stdio.
Sourcepub async fn initialize(&self) -> Result<InitializeResult, McpError>
pub async fn initialize(&self) -> Result<InitializeResult, McpError>
Initialize the connection.
This must be called before using any other methods.
Sourcepub async fn is_initialized(&self) -> bool
pub async fn is_initialized(&self) -> bool
Check if the client is initialized.
Sourcepub async fn server_capabilities(&self) -> Option<ServerCapabilities>
pub async fn server_capabilities(&self) -> Option<ServerCapabilities>
Get server capabilities.
Sourcepub async fn server_info(&self) -> Option<Implementation>
pub async fn server_info(&self) -> Option<Implementation>
Get server info.
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<ListResourcesResult, McpError>
pub async fn list_resources(&self) -> Result<ListResourcesResult, McpError>
List available resources.
Sourcepub async fn read_resource(
&self,
uri: &str,
) -> Result<ReadResourceResult, McpError>
pub async fn read_resource( &self, uri: &str, ) -> Result<ReadResourceResult, McpError>
Read a resource.
Sourcepub async fn list_prompts(&self) -> Result<ListPromptsResult, McpError>
pub async fn list_prompts(&self) -> Result<ListPromptsResult, McpError>
List available prompts.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected.
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