### Setup Plugin System Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/plugin_system/README.md Basic setup instructions for the plugin system example. Requires copying a .env file and adding a Google API key. ```bash cd examples/plugin_system cp .env.example .env # Edit .env and add your Google API key ``` -------------------------------- ### Run Quickstart Tier Examples Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/tier_examples/README.md Commands to execute examples for the quickstart feature tier, covering scaffolded project code, adding custom tools, and a zero-config alternative. ```bash cargo run --bin 08-quickstart-scaffold cargo run --bin 09-quickstart-tools cargo run --bin 10-quickstart-zero-config ``` -------------------------------- ### Run Quick Start Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/README.md Clone the ADK-Rust playground repository, set your API key, and run the quickstart example. ```bash git clone https://github.com/zavora-ai/adk-playground.git cd adk-playground # Set your API key export GOOGLE_API_KEY="your-key" # Run any example cargo run --example quickstart ``` -------------------------------- ### Setup ACP Server Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/acp_server/README.md Navigate to the example directory, copy the environment file, and add your API key. ```bash cd examples/acp_server cp .env.example .env # Edit .env and add your GOOGLE_API_KEY ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/prompt_optimizer/README.md Before running the example, ensure the GOOGLE_API_KEY environment variable is set. Copy the example environment file and edit it to include your API key. ```bash cp .env.example .env # Edit .env and add your Google API key ``` -------------------------------- ### Setup Environment File Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/desktop_audio/README.md Copy and edit the example environment file to configure API keys for services like Gemini. ```bash cp examples/desktop_audio/.env.example examples/desktop_audio/.env # Edit .env and add your Gemini API key ``` -------------------------------- ### Copy Environment Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/a2a-research-agent/README.md Copy the example environment file to start configuring API keys for LLM providers. ```bash cp .env.example .env ``` -------------------------------- ### Quick Start: Connect to MCP Server and Use Tools Source: https://github.com/zavora-ai/adk-rust/wiki/tools/mcp-tools This example demonstrates how to start an MCP server, connect to it using McpToolset, filter and discover tools, add them to an agent, and run an interactive console. It also shows how to obtain a cancellation token for clean server shutdown. ```APIDOC ## Quick Start: Connect to MCP Server and Use Tools This example demonstrates how to start an MCP server, connect to it using `McpToolset`, filter and discover tools, add them to an agent, and run an interactive console. It also shows how to obtain a cancellation token for clean server shutdown. ```rust use adk_agent::LlmAgentBuilder; use adk_core::{Content, Part, ReadonlyContext, Toolset}; use adk_model::GeminiModel; use adk_tool::McpToolset; use rmcp::{ServiceExt, transport::TokioChildProcess}; use tokio::process::Command; use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); // 1. Start MCP server and connect let mut cmd = Command::new("npx"); cmd.arg("-y").arg("@modelcontextprotocol/server-everything"); let client = ().serve(TokioChildProcess::new(cmd)?).await?; // 2. Create toolset from the client let toolset = McpToolset::new(client) .with_tools(&["echo", "add"]); // Only expose these tools // 3. Get cancellation token for cleanup let cancel_token = toolset.cancellation_token().await; // 4. Discover tools and add to agent let ctx: Arc = Arc::new(SimpleContext); let tools = toolset.tools(ctx).await?; let mut builder = LlmAgentBuilder::new("mcp_agent") .model(model) .instruction("You have MCP tools. Use 'echo' to repeat messages, 'add' to sum numbers."); for tool in tools { builder = builder.tool(tool); } let agent = builder.build()?; // 5. Run interactive console adk_cli::console::run_console( Arc::new(agent), "mcp_agent".to_string(), "user".to_string(), ).await?; // 6. Cleanup: shutdown MCP server cancel_token.cancel(); Ok(()) } // Minimal context for tool discovery struct SimpleContext; #[async_trait::async_trait] impl ReadonlyContext for SimpleContext { fn invocation_id(&self) -> &str { "init" } fn agent_name(&self) -> &str { "init" } fn user_id(&self) -> &str { "user" } fn app_name(&self) -> &str { "mcp" } fn session_id(&self) -> &str { "init" } fn branch(&self) -> &str { "main" } fn user_content(&self) -> &Content { static CONTENT: std::sync::OnceLock = std::sync::OnceLock::new(); CONTENT.get_or_init(|| Content::new("user").with_text("init")) } } ``` Run with: ```bash GOOGLE_API_KEY=your_key cargo run --bin basic ``` ``` -------------------------------- ### Dev Environment Setup Options Source: https://github.com/zavora-ai/adk-rust/blob/main/README.md Choose a method for setting up the development environment: Nix/devenv for reproducibility, a setup script for convenience, or manual installation of sccache for faster builds. ```bash # Option A: Nix/devenv (reproducible — identical on Linux, macOS, CI) devenv shell ``` ```bash # Option B: Setup script (installs sccache, cmake, etc.) ./scripts/setup-dev.sh ``` ```bash # Option C: Manual — just install sccache for faster builds brew install sccache && echo 'export RUSTC_WRAPPER=sccache' >> ~/.zshrc ``` -------------------------------- ### Setup Dev Environment Script Source: https://github.com/zavora-ai/adk-rust/blob/main/CONTRIBUTING.md Use the provided script to install recommended development tools for your platform. ```bash ./scripts/setup-dev.sh # Install recommended tools ./scripts/setup-dev.sh --check # Just check what's installed ``` -------------------------------- ### Quick Start: Connect to MCP Server and Use Tools Source: https://github.com/zavora-ai/adk-rust/wiki/mcp-tools This example demonstrates starting an MCP server, connecting to it, filtering tools, building an agent, and running an interactive console. It requires Node.js, npm, and an LLM API key. Ensure the `GOOGLE_API_KEY` environment variable is set. ```rust use adk_agent::LlmAgentBuilder; use adk_core::{Content, Part, ReadonlyContext, Toolset}; use adk_model::GeminiModel; use adk_tool::McpToolset; use rmcp::{ServiceExt, transport::TokioChildProcess}; use tokio::process::Command; use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); // 1. Start MCP server and connect let mut cmd = Command::new("npx"); cmd.arg("-y").arg("@modelcontextprotocol/server-everything"); let client = ().serve(TokioChildProcess::new(cmd)?).await?; // 2. Create toolset from the client let toolset = McpToolset::new(client) .with_tools(&["echo", "add"]); // Only expose these tools // 3. Get cancellation token for cleanup let cancel_token = toolset.cancellation_token().await; // 4. Discover tools and add to agent let ctx: Arc = Arc::new(SimpleContext); let tools = toolset.tools(ctx).await?; let mut builder = LlmAgentBuilder::new("mcp_agent") .model(model) .instruction("You have MCP tools. Use 'echo' to repeat messages, 'add' to sum numbers."); for tool in tools { builder = builder.tool(tool); } let agent = builder.build()?; // 5. Run interactive console adk_cli::console::run_console( Arc::new(agent), "mcp_demo".to_string(), "user".to_string(), ).await?; // 6. Cleanup: shutdown MCP server cancel_token.cancel(); Ok(()) } // Minimal context for tool discovery struct SimpleContext; #[async_trait::async_trait] impl ReadonlyContext for SimpleContext { fn invocation_id(&self) -> &str { "init" } fn agent_name(&self) -> &str { "init" } fn user_id(&self) -> &str { "user" } fn app_name(&self) -> &str { "mcp" } fn session_id(&self) -> &str { "init" } fn branch(&self) -> &str { "main" } fn user_content(&self) -> &Content { static CONTENT: std::sync::OnceLock = std::sync::OnceLock::new(); CONTENT.get_or_init(|| Content::new("user").with_text("init")) } } ``` ```bash GOOGLE_API_KEY=your_key cargo run --bin basic ``` -------------------------------- ### Quickstart: Initialize an LlmAgent Source: https://github.com/zavora-ai/adk-rust/wiki/introduction A basic example demonstrating how to initialize an LlmAgent with a Gemini model. Ensure the GOOGLE_API_KEY environment variable is set. ```rust use adk_rust::prelude::*; use std::sync::Arc; #[tokio::main] async fn main() -> std::result::Result<(), Box> { let api_key = std::env::var("GOOGLE_API_KEY")?; let model = GeminiModel::new(&api_key, "gemini-2.5-flash")?; let agent = LlmAgentBuilder::new("assistant") .description("A helpful AI assistant") .model(Arc::new(model)) .build()?; println!("Agent '{}' ready!", agent.name()); Ok(()) } ``` -------------------------------- ### Setup ADK-Rust Project Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/retry_reflect/README.md Navigate to the example directory and copy the environment configuration file. Ensure your Google API key is added to the .env file. ```bash cd examples/retry_reflect cp .env.example .env # Edit .env and add your Google API key ``` -------------------------------- ### Start ADK-Rust Server with Launcher Source: https://github.com/zavora-ai/adk-rust/wiki/deployment/server Initialize and run the ADK-Rust server using the Launcher. This example demonstrates setting up an LLM agent with Gemini and starting the server. ```rust use adk_rust::prelude::*; use adk_rust::Launcher; use std::sync::Arc; #[tokio::main] async fn main() -> Result<()> { let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); let agent = LlmAgentBuilder::new("my_agent") .description("A helpful assistant") .instruction("You are a helpful assistant.") .model(model) .build()?; Launcher::new(Arc::new(agent)).run().await } ``` -------------------------------- ### GET Webhook Example Source: https://github.com/zavora-ai/adk-rust/wiki/studio/triggers Demonstrates how to trigger a webhook with a GET request, including passing a message parameter. ```bash GET /api/projects/:id/webhook/my-path?message=Hello ``` -------------------------------- ### Setting Up Development Environment Source: https://github.com/zavora-ai/adk-rust/blob/main/docs/official_docs/development/development-guidelines.md Commands to clone the repository, set up the development environment using Nix or a setup script, install a parallel test runner, and run initial checks. ```bash git clone https://github.com/zavora-ai/adk-rust.git cd adk-rust # Option A: Nix/devenv (reproducible — identical on Linux, macOS, CI) devenv shell # Option B: Setup script (installs sccache, cmake, etc.) ./scripts/setup-dev.sh # Option C: Manual cargo build # Install cargo-nextest (parallel test runner, ~10x faster) curl -LsSf https://get.nexte.st/latest/mac | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin # Run all tests cargo nextest run --workspace # Check for lints cargo clippy --all-targets --all-features # Format code cargo fmt --all ``` -------------------------------- ### Complete MCP Tools Example Source: https://github.com/zavora-ai/adk-rust/wiki/tools/mcp-tools A full working example demonstrating the setup, discovery, and use of MCP tools with an LLM agent, including proper cleanup of the MCP server. ```rust use adk_agent::LlmAgentBuilder; use adk_core::{Content, Part, ReadonlyContext, Toolset}; use adk_model::GeminiModel; use adk_tool::McpToolset; use rmcp::{ServiceExt, transport::TokioChildProcess}; use std::sync::Arc; use tokio::process::Command; struct SimpleContext; #[async_trait::async_trait] impl ReadonlyContext for SimpleContext { fn invocation_id(&self) -> &str { "init" } fn agent_name(&self) -> &str { "init" } fn user_id(&self) -> &str { "user" } fn app_name(&self) -> &str { "mcp" } fn session_id(&self) -> &str { "init" } fn branch(&self) -> &str { "main" } fn user_content(&self) -> &Content { static CONTENT: std::sync::OnceLock = std::sync::OnceLock::new(); CONTENT.get_or_init(|| Content::new("user").with_text("init")) } } #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); println!("Starting MCP server..."); let mut cmd = Command::new("npx"); cmd.arg("-y").arg("@modelcontextprotocol/server-everything"); let client = ().serve(TokioChildProcess::new(cmd)?).await?; println!("MCP server connected!"); // Create filtered toolset let toolset = McpToolset::new(client) .with_name("everything-tools") .with_filter(|name| matches!(name, "echo" | "add" | "printEnv")); // Get cancellation token for cleanup let cancel_token = toolset.cancellation_token().await; // Discover tools let ctx = Arc::new(SimpleContext) as Arc; let tools = toolset.tools(ctx).await?; println!("Discovered {} tools:", tools.len()); for tool in &tools { println!(" - {}: {}", tool.name(), tool.description()); } // Build agent with tools let mut builder = LlmAgentBuilder::new("mcp_demo") .model(model) .instruction( "You have access to MCP tools:\n\u0000 - echo: Repeat a message back\n\u0000 - add: Add two numbers (a + b)\n\u0000 - printEnv: Print environment variables" ); for tool in tools { builder = builder.tool(tool); } let agent = builder.build()?; // Run interactive console let result = adk_cli::console::run_console( Arc::new(agent), "mcp_demo".to_string(), "user".to_string(), ).await; // Cleanup println!("\nShutting down MCP server..."); cancel_token.cancel(); tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; result?; Ok(()) } ``` -------------------------------- ### Environment Variables Setup Source: https://github.com/zavora-ai/adk-rust/blob/main/CONTRIBUTING.md Copy the example environment file and fill in necessary API keys for testing different providers. Ensure .env files are never committed. ```bash cp .env.example .env # Edit .env with your keys (GOOGLE_API_KEY, OPENAI_API_KEY, etc.) ``` -------------------------------- ### Full MCP Agent Example with Tokio Source: https://github.com/zavora-ai/adk-rust/blob/main/docs/official_docs/tools/mcp-tools.md A complete, runnable example demonstrating the setup and execution of an LLM agent that utilizes MCP tools. It includes server startup, tool discovery, agent building, and interactive console execution, along with proper cleanup procedures. ```rust use adk_agent::LlmAgentBuilder; use adk_core::{Content, Part, ReadonlyContext, Toolset}; use adk_model::GeminiModel; use adk_tool::McpToolset; use rmcp::{ServiceExt, transport::TokioChildProcess}; use std::sync::Arc; use tokio::process::Command; struct SimpleContext; #[async_trait::async_trait] impl ReadonlyContext for SimpleContext { fn invocation_id(&self) -> &str { "init" } fn agent_name(&self) -> &str { "init" } fn user_id(&self) -> &str { "user" } fn app_name(&self) -> &str { "mcp" } fn session_id(&self) -> &str { "init" } fn branch(&self) -> &str { "main" } fn user_content(&self) -> &Content { static CONTENT: std::sync::OnceLock = std::sync::OnceLock::new(); CONTENT.get_or_init(|| Content::new("user").with_text("init")) } } #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); println!("Starting MCP server..."); let mut cmd = Command::new("npx"); cmd.arg("-y").arg("@modelcontextprotocol/server-everything"); let client = ().serve(TokioChildProcess::new(cmd)?).await?; println!("MCP server connected!"); // Create filtered toolset let toolset = McpToolset::new(client) .with_name("everything-tools") .with_filter(|name| matches!(name, "echo" | "add" | "printEnv")); // Get cancellation token for cleanup let cancel_token = toolset.cancellation_token().await; // Discover tools let ctx = Arc::new(SimpleContext) as Arc; let tools = toolset.tools(ctx).await?; println!("Discovered {} tools:", tools.len()); for tool in &tools { println!(" - {}: {}", tool.name(), tool.description()); } // Build agent with tools let mut builder = LlmAgentBuilder::new("mcp_demo") .model(model) .instruction( "You have access to MCP tools:\n\ - echo: Repeat a message back\n\ - add: Add two numbers (a + b)\n\ - printEnv: Print environment variables" ); for tool in tools { builder = builder.tool(tool); } let agent = builder.build()?; // Run interactive console let result = adk_cli::console::run_console( Arc::new(agent), "mcp_demo".to_string(), "user".to_string(), ).await; // Cleanup println!("\nShutting down MCP server..."); cancel_token.cancel(); tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; result?; Ok(()) } ``` -------------------------------- ### Basic Browser Session and Agent Setup Source: https://github.com/zavora-ai/adk-rust/wiki/browser-tools Configure and start a browser session, create a toolset with all available browser tools, and initialize an AI agent with these tools. ```rust use adk_browser::{BrowserSession, BrowserToolset, BrowserConfig}; use adk_agent::LlmAgentBuilder; use adk_model::GeminiModel; use std::sync::Arc; #[tokio::main] async fn main() -> Result<(), Box> { // Configure browser session let config = BrowserConfig::new() .webdriver_url("http://localhost:4444") .headless(true) .viewport(1920, 1080); // Create and start browser session let browser = Arc::new(BrowserSession::new(config)); browser.start().await?; // Create toolset with all 46 tools let toolset = BrowserToolset::new(browser.clone()); let tools = toolset.all_tools(); // Create AI agent with browser tools let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); let mut builder = LlmAgentBuilder::new("web_agent") .model(model) .instruction("You are a web automation assistant. Use browser tools to help users."); for tool in tools { builder = builder.tool(tool); } let agent = builder.build()?; // Clean up when done browser.stop().await?; Ok(()) } ``` -------------------------------- ### Create README Files for Crates Source: https://github.com/zavora-ai/adk-rust/wiki/development/development-guidelines Each crate should include a `README.md` file containing a brief description, installation instructions, a quick example, and a link to full documentation. ```markdown 1. Brief description 2. Installation instructions 3. Quick example 4. Link to full documentation ``` -------------------------------- ### Clone and Set Up ADK-Rust Development Environment Source: https://github.com/zavora-ai/adk-rust/wiki/development/development-guidelines Instructions for cloning the repository and setting up the development environment using Nix, a setup script, or manually. Includes installing a parallel test runner. ```bash # Clone the repository git clone https://github.com/zavora-ai/adk-rust.git cd adk-rust # Option A: Nix/devenv (reproducible — identical on Linux, macOS, CI) devenv shell # Option B: Setup script (installs sccache, cmake, etc.) ./scripts/setup-dev.sh # Option C: Manual cargo build # Install cargo-nextest (parallel test runner, ~10x faster) curl -LsSf https://get.nexte.st/latest/mac | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin # Run all tests cargo nextest run --workspace # Check for lints cargo clippy --all-targets --all-features # Format code cargo fmt --all ``` -------------------------------- ### Run ui_agent Example Source: https://github.com/zavora-ai/adk-rust/wiki/tools/ui-tools Demonstrates how to run the ui_agent example for console interaction. ```bash cargo run --bin ui_agent ``` -------------------------------- ### Set API Key and Run Examples Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-gemini/README.md Before running any examples, set your GEMINI_API_KEY environment variable. Then, use cargo run with the -p adk-gemini flag followed by --example and the example name. ```bash export GEMINI_API_KEY=your-api-key cargo run -p adk-gemini --example simple cargo run -p adk-gemini --example streaming cargo run -p adk-gemini --example tools cargo run -p adk-gemini --example google_search cargo run -p adk-gemini --example thinking_basic cargo run -p adk-gemini --example simple_thought_signature cargo run -p adk-gemini --example thought_signature_example cargo run -p adk-gemini --example embedding cargo run -p adk-gemini --example image_generation cargo run -p adk-gemini --example structured_response cargo run -p adk-gemini --example cache_basic cargo run -p adk-gemini --example batch_generate cargo run -p adk-gemini --example url_context cargo run -p adk-gemini --example simple_speech_generation ``` -------------------------------- ### Run Prompt Optimizer Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/prompt_optimizer/README.md Execute the prompt optimizer example using Cargo. This command builds and runs the specified example from the Cargo.toml manifest. ```bash cargo run --manifest-path examples/prompt_optimizer/Cargo.toml ``` -------------------------------- ### Run MCP Server Manager Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/mcp_manager/README.md Execute the example using Cargo. This command builds and runs the MCP server manager example. ```bash cargo run --manifest-path examples/mcp_manager/Cargo.toml ``` -------------------------------- ### Run YAML Agent Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/yaml_agent/README.md Command to set up the environment by copying the example .env file and then run the YAML agent definition example using Cargo. ```bash # Copy and fill in your API key cp .env.example .env # Run the example cargo run --manifest-path examples/yaml_agent/Cargo.toml ``` -------------------------------- ### Quick Start: Evaluating an Agent with adk-eval Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-eval/README.md Demonstrates the basic setup for evaluating an agent using adk-eval. It shows how to create an agent, configure evaluation criteria, run evaluations from a file, and interpret the results. ```rust use adk_eval::{Evaluator, EvaluationConfig, EvaluationCriteria}; use std::sync::Arc; #[tokio::main] async fn main() -> Result<(), Box> { // Create your agent let agent = create_my_agent()?; // Configure evaluator with criteria let config = EvaluationConfig::with_criteria( EvaluationCriteria::exact_tools() .with_response_similarity(0.8) ); let evaluator = Evaluator::new(config); // Run evaluation let report = evaluator .evaluate_file(agent, "tests/my_agent.test.json") .await?; // Check results if report.all_passed() { println!("All tests passed!"); } else { println!("{}", report.format_summary()); } Ok(()) } ``` -------------------------------- ### Run DeepSeek V4 Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/deepseek_v4/README.md Navigate to the example directory, copy the environment file, set your DeepSeek API key, and run the example using Cargo. ```bash cd examples/deepseek_v4 cp .env.example .env # add your DEEPSEEK_API_KEY cargo run ``` -------------------------------- ### Run Agent Registry Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/agent_registry/README.md Execute the agent registry example using Cargo. Ensure you have Rust 1.85+ installed. ```bash cargo run --manifest-path examples/agent_registry/Cargo.toml ``` -------------------------------- ### Install ADK Studio from crates.io Source: https://github.com/zavora-ai/adk-rust/wiki/studio/studio Installs the ADK Studio as a self-contained binary using Cargo. This is the recommended method for quick setup. ```bash cargo install adk-studio ``` -------------------------------- ### Simple Thought Signature Example Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-gemini/examples/README.md Provides a basic example of using 'thought signatures' to guide the model's reasoning process. ```rust use adk_gemini::gemini_pro; use adk_gemini::types::ThoughtSignature; #[tokio::main] async fn main() -> Result<(), Box> { let api_key = std::env::var("GEMINI_API_KEY").expect("GEMINI_API_KEY must be set"); let client = adk_gemini::Client::new(api_key); let prompt = "What are the main benefits of using Rust?"; let thought_signatures = vec![ ThoughtSignature::new("Identify key benefits."), ThoughtSignature::new("Elaborate on each benefit.") ]; let response = client.generate_content_with_thought_signatures(prompt, thought_signatures).await?; println!("Simple Thought Signature Response: {}", response.text()); Ok(()) } ``` -------------------------------- ### Basic Agent Setup with UI Tools Source: https://github.com/zavora-ai/adk-rust/blob/main/docs/official_docs/tools/ui-tools.md Demonstrates how to initialize an AI agent with all available UI tools for user interaction. ```rust ```rust use adk_rust::prelude::*; use adk_ui::UiToolset; use std::sync::Arc; #[tokio::main] async fn main() -> Result<(), Box> { let model = Arc::new(GeminiModel::from_env("gemini-2.5-flash")?); // Get all 10 UI tools let ui_tools = UiToolset::all_tools(); // Create AI agent with UI tools let mut builder = LlmAgentBuilder::new("ui_agent") .model(model) .instruction(r#" You are a helpful assistant that uses UI components to interact with users. Use render_form for collecting information. Use render_card for displaying results. Use render_alert for notifications. Use render_modal for confirmation dialogs. Use render_toast for brief status messages. "#); for tool in ui_tools { builder = builder.tool(tool); } let agent = builder.build()?; Ok(()) } ``` ``` -------------------------------- ### Complete Ollama Agent Example Source: https://github.com/zavora-ai/adk-rust/wiki/models/ollama A full Rust example demonstrating the setup of an Ollama-powered agent, including dependencies, configuration, and running an interactive session. ```rust use adk_rust::prelude::*; use adk_rust::Launcher; use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); // No API key needed! let model = OllamaModel::new(OllamaConfig::new("llama3.2"))?; let agent = LlmAgentBuilder::new("ollama_assistant") .description("Ollama-powered local assistant") .instruction("You are a helpful assistant running locally via Ollama. Be concise.") .model(Arc::new(model)) .build()?; // Run interactive session Launcher::new(Arc::new(agent)).run().await?; Ok(()) } ``` -------------------------------- ### Run ui_server Example Source: https://github.com/zavora-ai/adk-rust/wiki/tools/ui-tools Demonstrates how to run the ui_server example for an HTTP server with SSE. ```bash cargo run --bin ui_server ``` -------------------------------- ### GitHub Actions CI/CD Integration Example Source: https://github.com/zavora-ai/adk-rust/blob/main/docs/roadmap/evaluation.md Example GitHub Actions workflow for running agent evaluations on push or pull request events, including setup and artifact upload. ```yaml name: Agent Evaluation on: [push, pull_request] jobs: evaluate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Rust uses: actions-rs/toolchain@v1 - name: Run Evaluations env: GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} run: | cargo test --test agent_evaluation - name: Upload Results uses: actions/upload-artifact@v2 with: name: evaluation-results path: target/eval-results/ ``` -------------------------------- ### Complete Groq Example Source: https://github.com/zavora-ai/adk-rust/wiki/models/providers Sets up and runs an agent using the Groq provider. Ensure the GROQ_API_KEY environment variable is set. ```rust use adk_rust::prelude::*; use adk_rust::Launcher; use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let api_key = std::env::var("GROQ_API_KEY")?; let model = GroqClient::llama70b(&api_key)?; let agent = LlmAgentBuilder::new("groq_assistant") .description("Groq-powered assistant") .instruction("You are a helpful assistant powered by Groq. Be concise and fast.") .model(Arc::new(model)) .build()?; Launcher::new(Arc::new(agent)).run().await?; Ok(()) } ``` -------------------------------- ### Run ui_react_client Example Source: https://github.com/zavora-ai/adk-rust/wiki/tools/ui-tools Demonstrates how to run the ui_react_client example for a React frontend. Ensure you are in the ui_react_client directory. ```bash cd ui_react_client && npm run dev ``` -------------------------------- ### API Connectivity Test Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-gemini/examples/README.md A simple test to verify API connectivity. This example is useful for initial setup checks. ```rust use adk_gemini::gemini_pro; #[tokio::main] async fn main() -> Result<(), Box> { let api_key = std::env::var("GEMINI_API_KEY").expect("GEMINI_API_KEY must be set"); let client = adk_gemini::Client::new(api_key); // This is a minimal prompt to test connectivity. let prompt = "Hello"; let response = client.generate_content(prompt).await?; println!("API connectivity test successful. Response: {}", response.text()); Ok(()) } ``` -------------------------------- ### Build and Run MCP Sampling Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/mcp_sampling/README.md Instructions for building the `sampling-server` and `sampling-client` binaries and running the client. The client automatically spawns the server and connects to it. ```bash export GOOGLE_API_KEY=your_key # Build both binaries cargo build --manifest-path examples/mcp_sampling/Cargo.toml # Run the agent (spawns the server automatically) cargo run --manifest-path examples/mcp_sampling/Cargo.toml --bin sampling-client ``` -------------------------------- ### Multi-Collection Search Example Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-rag/README.md Demonstrates how to perform searches across multiple collections in a RAG setup. Requires an API key. ```bash cargo run --example rag_multi_collection --features rag-gemini ``` -------------------------------- ### Run Basic Content Generation Example Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-gemini/examples/README.md Execute the 'simple' example to understand the fundamental API usage of the Gemini library. Ensure the GEMINI_API_KEY environment variable is set. ```bash GEMINI_API_KEY="your-api-key" cargo run --example simple ``` -------------------------------- ### A2A v1.0.0 Server Setup Source: https://github.com/zavora-ai/adk-rust/wiki/deployment/a2a Example Rust code demonstrating the setup of a full A2A v1.0.0 server with LLM integration, including agent creation, A2A infrastructure, agent card building, runner configuration, and serving the application. ```APIDOC ## Exposing an Agent via A2A v1 Build a full A2A v1.0.0 server with LLM integration: ```rust use std::sync::Arc; use a2a_protocol_types::{AgentCapabilities, AgentSkill}; use adk_agent::LlmAgentBuilder; use adk_server::a2a::v1::card::{CachedAgentCard, build_v1_agent_card}; use adk_server::a2a::v1::executor::V1Executor; use adk_server::a2a::v1::jsonrpc_handler::jsonrpc_handler; use adk_server::a2a::v1::push::NoOpPushNotificationSender; use adk_server::a2a::v1::request_handler::RequestHandler; use adk_server::a2a::v1::rest_handler::rest_router; use adk_server::a2a::v1::task_store::InMemoryTaskStore; use adk_server::a2a::v1::version::version_negotiation; use adk_runner::RunnerConfig; use adk_session::InMemorySessionService; use axum::Router; use axum::routing::post; use tokio::sync::RwLock; // 1. Create your agent let model = adk_model::GeminiModel::new(&api_key, "gemini-2.5-flash")?; let agent = LlmAgentBuilder::new("my-agent") .description("A helpful agent") .model(Arc::new(model)) .instruction("You are a helpful assistant.") .build()?; // 2. Set up A2A infrastructure let task_store = Arc::new(InMemoryTaskStore::new()); let executor = Arc::new(V1Executor::new(task_store.clone())); let push_sender = Arc::new(NoOpPushNotificationSender); // 3. Build agent card with capabilities let card = build_v1_agent_card( "my-agent", "A helpful agent", "http://localhost:3001/jsonrpc", "1.0.0", vec![/* skills */], AgentCapabilities::none().with_streaming(true), ); let cached_card = Arc::new(RwLock::new(CachedAgentCard::new(card))); // 4. Create runner config for LLM invocation let session_service = Arc::new(InMemorySessionService::new()); let runner_config = Arc::new(RunnerConfig { app_name: "my-agent".to_string(), agent: Arc::new(agent), session_service, artifact_service: None, memory_service: None, plugin_manager: None, run_config: None, compaction_config: None, context_cache_config: None, cache_capable: None, request_context: None, cancellation_token: None, }); // 5. Wire up the handler and routes let handler = Arc::new(RequestHandler::with_runner( executor, task_store, push_sender, cached_card, runner_config, )); let app = Router::new() .route("/jsonrpc", post(jsonrpc_handler)) .with_state(handler.clone()) .merge(rest_router(handler)) .layer(axum::middleware::from_fn(version_negotiation)); // 6. Serve let listener = tokio::net::TcpListener::bind("0.0.0.0:3001").await?; axum::serve(listener, app).await?; ``` This exposes: - `GET /.well-known/agent-card.json` — Agent card with ETag caching - `POST /jsonrpc` — JSON-RPC endpoint (all 11 v1 operations) - REST routes for all operations - `A2A-Version` header negotiation on all routes ``` -------------------------------- ### Run Spanner Toolset Example Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/spanner_toolset/README.md Execute the Spanner toolset example in dry-run or live mode. Dry-run mode requires no GCP project setup, while live mode requires environment variables and authentication for real Spanner API calls. ```bash # Dry-run mode (no GCP project needed) cargo run --manifest-path examples/spanner_toolset/Cargo.toml # Live mode export SPANNER_PROJECT_ID=your-gcp-project-id export SPANNER_INSTANCE_ID=your-spanner-instance-id export SPANNER_DATABASE_ID=your-spanner-database-id gcloud auth application-default login cargo run --manifest-path examples/spanner_toolset/Cargo.toml ``` -------------------------------- ### Basic Setup with VertexAI Sessions Source: https://github.com/zavora-ai/adk-rust/blob/main/docs/roadmap/vertex-ai-session.md Illustrates the basic setup for a runner application using the VertexAI Session Service. It initializes the service with project ID from environment variables and integrates it into the runner configuration. ```rust use adk_session::{VertexAISessionService, VertexAIConfig}; use adk_runner::{Runner, RunnerConfig}; #[tokio::main] async fn main() -> Result<(), Box> { // Initialize VertexAI session service let session_service = VertexAISessionService::new(VertexAIConfig { project_id: env::var("GCP_PROJECT_ID")?, location: "us-central1".to_string(), credentials_path: None, // Use ADC })?; // Create runner with VertexAI sessions let runner = Runner::new(RunnerConfig { app_name: "my_agent".to_string(), agent: my_agent, session_service: Arc::new(session_service), artifact_service: None, memory_service: None, })?; // Sessions now persist in Vertex AI! Ok(()) } ``` -------------------------------- ### Complete ADK-Rust MCP Agent Example Source: https://github.com/zavora-ai/adk-rust/wiki/mcp-tools A full working example demonstrating how to build an LLM agent with MCP tools, connect to an MCP server, and run an interactive console. Includes setup, tool discovery, agent building, and cleanup. ```rust use adk_agent::LlmAgentBuilder; use adk_core::{Content, Part, ReadonlyContext, Toolset}; use adk_model::GeminiModel; use adk_tool::McpToolset; use rmcp::{ServiceExt, transport::TokioChildProcess}; use std::sync::Arc; use tokio::process::Command; struct SimpleContext; #[async_trait::async_trait] impl ReadonlyContext for SimpleContext { fn invocation_id(&self) -> &str { "init" } fn agent_name(&self) -> &str { "init" } fn user_id(&self) -> &str { "user" } fn app_name(&self) -> &str { "mcp" } fn session_id(&self) -> &str { "init" } fn branch(&self) -> &str { "main" } fn user_content(&self) -> &Content { static CONTENT: std::sync::OnceLock = std::sync::OnceLock::new(); CONTENT.get_or_init(|| Content::new("user").with_text("init")) } } #[tokio::main] async fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); let api_key = std::env::var("GOOGLE_API_KEY")?; let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); println!("Starting MCP server..."); let mut cmd = Command::new("npx"); cmd.arg("-y").arg("@modelcontextprotocol/server-everything"); let client = ().serve(TokioChildProcess::new(cmd)?).await?; println!("MCP server connected!"); // Create filtered toolset let toolset = McpToolset::new(client) .with_name("everything-tools") .with_filter(|name| matches!(name, "echo" | "add" | "printEnv")); // Get cancellation token for cleanup let cancel_token = toolset.cancellation_token().await; // Discover tools let ctx = Arc::new(SimpleContext) as Arc; let tools = toolset.tools(ctx).await?; println!("Discovered {} tools:", tools.len()); for tool in &tools { println!(" - {}: {}", tool.name(), tool.description()); } // Build agent with tools let mut builder = LlmAgentBuilder::new("mcp_demo") .model(model) .instruction( "You have access to MCP tools:\n\ - echo: Repeat a message back\n\ - add: Add two numbers (a + b)\n\ - printEnv: Print environment variables" ); for tool in tools { builder = builder.tool(tool); } let agent = builder.build()?; // Run interactive console let result = adk_cli::console::run_console( Arc::new(agent), "mcp_demo".to_string(), "user".to_string(), ).await; // Cleanup println!("\nShutting down MCP server..."); cancel_token.cancel(); tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; result?; Ok(()) } ``` -------------------------------- ### Run AWP Agent Example Source: https://github.com/zavora-ai/adk-rust/wiki/deployment/awp Provides the command-line instructions to set up and run a complete AWP agent example, including loading business configuration, creating an LLM agent, and serving AWP endpoints. ```bash cd examples/awp_agent cp .env.example .env # add your GOOGLE_API_KEY cargo run ``` -------------------------------- ### Complete Launcher Example in Rust Source: https://github.com/zavora-ai/adk-rust/wiki/deployment/launcher Demonstrates setting up an agent with tools and running it using the Launcher. Ensure the 'GOOGLE_API_KEY' environment variable is set and a 'cli-*' feature is enabled for full CLI/server mode. ```rust use adk_rust::prelude::*; use adk_rust::Launcher; use std::sync::Arc; #[tokio::main] async fn main() -> Result<()> { // Load API key let api_key = std::env::var("GOOGLE_API_KEY") .expect("GOOGLE_API_KEY environment variable not set"); // Create model let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?); // Create agent with tools let weather_tool = FunctionTool::new( "get_weather", "Get the current weather for a location", |params, _ctx| async move { let location = params["location"].as_str().unwrap_or("unknown"); Ok(json!({ "location": location, "temperature": 72, "condition": "sunny" })) }, ); let agent = LlmAgentBuilder::new("weather_agent") .description("An agent that provides weather information") .instruction("You are a weather assistant. Use the get_weather tool to provide weather information.") .model(model) .tool(Arc::new(weather_tool)) .build()?; // Run with Launcher. Enable a `cli-*` feature for full CLI/server mode. Launcher::new(Arc::new(agent)) .app_name("weather_app") .run() .await } ``` -------------------------------- ### Initialize ACP Connection Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/acp_server/README.md Send an 'initialize' message to the ACP server via stdin to start the connection and get server capabilities. ```bash echo '{"method": "initialize", "params": {"protocol_version": "1.0"}}' | cargo run ``` -------------------------------- ### Anthropic (Claude) Integration Source: https://github.com/zavora-ai/adk-rust/blob/main/adk-model/README.md Integrate Anthropic's Claude models into ADK agents. This example shows basic client setup. ```APIDOC ## Anthropic (Claude) Integration ### Description Initialize and use the `AnthropicClient` for interacting with Anthropic's Claude models within the ADK. ### Method Rust SDK usage ### Endpoint N/A (SDK usage) ### Parameters N/A (SDK usage) ### Request Example ```rust use adk_model::anthropic::{AnthropicClient, AnthropicConfig}; use adk_agent::LlmAgentBuilder; use std::sync::Arc; #[tokio::main] async fn main() -> Result<(), Box> { let api_key = std::env::var("ANTHROPIC_API_KEY")?; let model = AnthropicClient::new(AnthropicConfig::new(api_key, "claude-sonnet-4-6"))?; let agent = LlmAgentBuilder::new("assistant") .model(Arc::new(model)) .build()?; Ok(()) } ``` ### Response N/A (SDK usage) ``` -------------------------------- ### Run Gemini Audio Examples Source: https://github.com/zavora-ai/adk-rust/blob/main/examples/gemini_audio/README.md Set your Google API key and run the examples using Cargo. ```bash export GOOGLE_API_KEY=your-key-here cargo run --manifest-path examples/gemini_audio/Cargo.toml ```