pub struct McpClient { /* private fields */ }Expand description
MCP client that connects to a single MCP server.
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub async fn connect(
provider: &Provider,
keyring: &Keyring,
) -> Result<Self, McpError>
pub async fn connect( provider: &Provider, keyring: &Keyring, ) -> Result<Self, McpError>
Connect to an MCP server based on the provider’s configuration.
For stdio: spawns the subprocess with env vars resolved from keyring. For HTTP: creates an HTTP client with auth headers.
Sourcepub async fn connect_with_gen(
provider: &Provider,
keyring: &Keyring,
gen_ctx: Option<&GenContext>,
auth_cache: Option<&AuthCache>,
) -> Result<Self, McpError>
pub async fn connect_with_gen( provider: &Provider, keyring: &Keyring, gen_ctx: Option<&GenContext>, auth_cache: Option<&AuthCache>, ) -> Result<Self, McpError>
Connect to an MCP server, optionally using a dynamic auth generator.
Sourcepub async fn list_tools(&self) -> Result<Vec<McpToolDef>, McpError>
pub async fn list_tools(&self) -> Result<Vec<McpToolDef>, McpError>
Discover tools via tools/list. Results are cached.
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: HashMap<String, Value>,
) -> Result<McpToolResult, McpError>
pub async fn call_tool( &self, name: &str, arguments: HashMap<String, Value>, ) -> Result<McpToolResult, McpError>
Execute a tool via tools/call.
Sourcepub async fn disconnect(&self)
pub async fn disconnect(&self)
Disconnect from the MCP server.
Sourcepub async fn invalidate_cache(&self)
pub async fn invalidate_cache(&self)
Invalidate cached tools (e.g., after tools/list_changed notification).
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