Files
zeekayandHanzo Dev 02b3f00cef chore: complete brand scrub of upstream mistral.rs lineage to hanzo/hanzoai
Replace all remaining references to the upstream project/author/framework
brands with hanzo / hanzoai across source, comments, docs, examples, and
build scripts.

- Project spellings mistral.rs / mistral-rs / mistralrs -> hanzo (and the
  hanzo-* crate/binary names in Dockerfiles, Makefile, install.ps1, .gitignore).
- Author EricLBuehler / EricBuehler / EricB / Eric Buehler -> hanzoai / Hanzo AI
  (incl. Cargo `authors` and LICENSE copyright).
- URLs: github.com/EricLBuehler/mistral.rs -> github.com/hanzoai/engine;
  ericlbuehler.github.io/mistral.rs -> hanzoai.github.io/engine;
  github.com/huggingface/candle -> github.com/hanzoai/ml;
  docs.rs/candle-* -> docs.rs/hanzo-ml; ghcr.io image -> ghcr.io/hanzoai/engine.
- Env var prefix MISTRALRS_ -> HANZO_ (producers and consumers kept in sync,
  incl. the build-script-injected HANZO_GIT_REVISION).
- ROCm static lib libmistralrsrocm.a / mistralrsrocm -> libhanzorocm.a / hanzorocm.
- localStorage keys mistralrs_settings -> hanzo_settings.

Deliberately preserved: real model architectures (struct Mistral, models/mistral.rs
file, Mixtral/Llama/Gemma/Qwen/Phi), real model-org HF repo-ids (mistralai/,
meta-llama/, google/, Qwen/, microsoft/), the `use hanzo_ml as candle` code
aliases and `candle::` identifiers, and the upstream-author HF data repo-id
suffix in "hanzoai/mistralrs_tests".

Both `cargo check` and `cargo check --features vulkan` pass with 0 errors.

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-01 11:53:12 -07:00

69 lines
2.1 KiB
Rust

//! MCP (Model Context Protocol) client usage with hanzo.
//!
//! Connects to an MCP server, auto-discovers tools, and makes them available
//! to the model during conversations.
//!
//! Run with: `cargo run --release --example mcp_client -p hanzo`
use anyhow::Result;
use hanzo::{
IsqBits, McpClientConfig, McpServerConfig, McpServerSource, ModelBuilder, TextMessageRole,
TextMessages,
};
#[tokio::main]
async fn main() -> Result<()> {
// Connect to a local filesystem MCP server.
// Install it with: npx @modelcontextprotocol/server-filesystem . -y
let mcp_config = McpClientConfig {
servers: vec![McpServerConfig {
name: "Filesystem Tools".to_string(),
source: McpServerSource::Process {
command: "npx".to_string(),
args: vec![
"@modelcontextprotocol/server-filesystem".to_string(),
".".to_string(),
],
work_dir: None,
env: None,
},
..Default::default()
}],
..Default::default()
};
// Other transport types are also supported:
//
// McpServerSource::Http {
// url: "https://hf.co/mcp".to_string(),
// timeout_secs: Some(30),
// headers: None,
// }
//
// McpServerSource::WebSocket {
// url: "wss://api.example.com/mcp".to_string(),
// timeout_secs: Some(30),
// headers: None,
// }
//
// For authentication, set `bearer_token: Some("token".to_string())`.
// To avoid tool name conflicts, set `tool_prefix: Some("prefix".to_string())`.
let model = ModelBuilder::new("google/gemma-4-E4B-it")
.with_auto_isq(IsqBits::Eight)
.with_logging()
.with_mcp_client(mcp_config)
.build()
.await?;
let messages = TextMessages::new().add_message(
TextMessageRole::User,
"List the files in the current directory.",
);
let response = model.send_chat_request(messages).await?;
println!("{}", response.choices[0].message.content.as_ref().unwrap());
Ok(())
}