Skip to main content

Crate adk_tool

Crate adk_tool 

Source
Expand description

§adk-tool

Tool system for ADK agents (FunctionTool, MCP, Google Search, AgentTool).

§Overview

This crate provides the tool infrastructure for ADK agents:

§Quick Start

use adk_tool::FunctionTool;
use adk_core::{ToolContext, Result};
use serde_json::{json, Value};
use std::sync::Arc;

async fn get_weather(ctx: Arc<dyn ToolContext>, args: Value) -> Result<Value> {
    let city = args["city"].as_str().unwrap_or("Unknown");
    Ok(json!({
        "city": city,
        "temperature": 72,
        "condition": "sunny"
    }))
}

let tool = FunctionTool::new(
    "get_weather",
    "Get current weather for a city",
    get_weather,
);

§MCP Integration

Connect to MCP servers for external tools:

use adk_tool::McpToolset;
use rmcp::{ServiceExt, transport::TokioChildProcess};

let client = ().serve(TokioChildProcess::new(
    Command::new("npx")
        .arg("-y")
        .arg("@modelcontextprotocol/server-filesystem")
        .arg("/path/to/files")
)?).await?;

let toolset = McpToolset::new(client);

Re-exports§

pub use builtin::ExitLoopTool;
pub use builtin::GoogleSearchTool;
pub use builtin::LoadArtifactsTool;
pub use mcp::McpAuth;
pub use mcp::McpHttpClientBuilder;
pub use mcp::McpTaskConfig;
pub use mcp::McpToolset;
pub use mcp::OAuth2Config;
pub use toolset::BasicToolset;
pub use toolset::FilteredToolset;
pub use toolset::MergedToolset;
pub use toolset::PrefixedToolset;
pub use toolset::string_predicate;

Modules§

builtin
mcp
toolset

Structs§

AgentTool
AgentTool wraps an Agent to make it callable as a Tool.
AgentToolConfig
Configuration options for AgentTool behavior.
FunctionTool

Enums§

AdkError
Unified error type for all ADK operations.

Traits§

Tool
ToolContext
Toolset

Type Aliases§

Result
Convenience alias used throughout ADK crates.

Attribute Macros§

tool
Attribute macro that generates a Tool implementation from an async function.