MCP Client Implementation
This crate provides a client for connecting to MCP (Model Context Protocol) servers.
It enables programmatic interaction with MCP servers for testing, proxying, and
building multi-hop MCP architectures.
Quick Start
use pulseengine_mcp_client::{McpClient, StdioClientTransport};
use tokio::process::Command;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut child = Command::new("my-mcp-server")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn()?;
let stdin = child.stdin.take().unwrap();
let stdout = child.stdout.take().unwrap();
let transport = StdioClientTransport::new(stdin, stdout);
let mut client = McpClient::new(transport);
let server_info = client.initialize("my-client", "1.0.0").await?;
println!("Connected to: {}", server_info.server_info.name);
let tools = client.list_tools().await?;
for tool in tools.tools {
println!("Tool: {}", tool.name);
}
Ok(())
}