pub struct McpClient { /* private fields */ }Expand description
MCP Client wrapper for connecting to MCP servers
Manages a connection to an MCP server and provides methods to:
- Discover available tools
- Execute tools remotely
§Example (when implemented)
// Connect to an MCP server via stdio
let client = McpClient::new_stdio("npx", &["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]).await?;
// Discover tools
let tools = client.list_tools().await?;
println!("Found {} tools", tools.len());Implementations§
Source§impl McpClient
impl McpClient
Sourcepub async fn new_stdio(
command: &str,
args: &[&str],
) -> Result<Arc<Self>, String>
pub async fn new_stdio( command: &str, args: &[&str], ) -> Result<Arc<Self>, String>
Create a new MCP client connected to a server via stdio
§Arguments
command- The command to run (e.g., “npx”, “python”, “node”)args- Arguments to pass (e.g., [“-y”, “@modelcontextprotocol/server-filesystem”, “/path”])
§Example MCP Servers
- Filesystem:
npx -y @modelcontextprotocol/server-filesystem /tmp - SQLite:
npx -y @modelcontextprotocol/server-sqlite --db-path ./data.db - Web:
npx -y @modelcontextprotocol/server-fetch
Sourcepub async fn list_tools(&self) -> Result<Vec<McpToolInfo>, String>
pub async fn list_tools(&self) -> Result<Vec<McpToolInfo>, String>
Discover all tools available on the connected MCP server
Sends a tools/list request to the MCP server and parses the response.
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