mistralrs-mcp/README.md
Model Context Protocol (MCP) client implementation for mistral.rs.
This crate provides a client library for connecting to MCP servers and integrating external tools with language models. It supports multiple transport protocols (HTTP, WebSocket, Process) and provides automatic tool discovery and registration.
use mistralrs_mcp::{McpClient, McpClientConfig, McpServerConfig, McpServerSource};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = McpClientConfig {
servers: vec![
McpServerConfig {
id: "web_search".to_string(),
name: "Web Search MCP".to_string(),
source: McpServerSource::Http {
url: "https://api.example.com/mcp".to_string(),
timeout_secs: Some(30),
headers: None,
},
enabled: true,
tool_prefix: Some("web".to_string()),
resources: None,
bearer_token: Some("your-api-token".to_string()),
},
],
auto_register_tools: true,
tool_timeout_secs: Some(30),
max_concurrent_calls: Some(10),
};
let mut client = McpClient::new(config);
client.initialize().await?;
let tools = client.get_tools();
println!("Discovered {} tools", tools.len());
Ok(())
}
See the MCP Client documentation for more details.