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>,
override_mcp_url: Option<&str>,
) -> Result<Self, McpError>
pub async fn connect_with_gen( provider: &Provider, keyring: &Keyring, gen_ctx: Option<&GenContext>, auth_cache: Option<&AuthCache>, override_mcp_url: Option<&str>, ) -> Result<Self, McpError>
Connect to an MCP server, optionally using a dynamic auth generator.
override_mcp_url: when Some, overrides the provider’s static
mcp_url for this connection. Used by the proxy to honour a
sandbox-supplied X-Ati-Upstream-Url after validating it against the
per-provider allowlist (issue #124). Ignored on stdio transport
(which has no URL — guarded at manifest load time).
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).