adk_tool/lib.rs
1//! # adk-tool
2//!
3//! Tool system for ADK agents (FunctionTool, MCP, Google Search, AgentTool).
4//!
5//! ## Overview
6//!
7//! This crate provides the tool infrastructure for ADK agents:
8//!
9//! - [`FunctionTool`] - Create tools from async Rust functions
10//! - [`AgentTool`] - Use agents as callable tools for composition
11//! - [`GoogleSearchTool`] - Web search via Gemini's grounding
12//! - [`McpToolset`] - Model Context Protocol integration
13//! - [`BasicToolset`] - Group multiple tools together
14//! - [`ExitLoopTool`] - Control flow for loop agents
15//! - [`LoadArtifactsTool`] - Inject binary artifacts into context
16//!
17//! ## Quick Start
18//!
19//! ```rust,no_run
20//! use adk_tool::FunctionTool;
21//! use adk_core::{ToolContext, Result};
22//! use serde_json::{json, Value};
23//! use std::sync::Arc;
24//!
25//! async fn get_weather(ctx: Arc<dyn ToolContext>, args: Value) -> Result<Value> {
26//! let city = args["city"].as_str().unwrap_or("Unknown");
27//! Ok(json!({
28//! "city": city,
29//! "temperature": 72,
30//! "condition": "sunny"
31//! }))
32//! }
33//!
34//! let tool = FunctionTool::new(
35//! "get_weather",
36//! "Get current weather for a city",
37//! get_weather,
38//! );
39//! ```
40//!
41//! ## MCP Integration
42//!
43//! Connect to MCP servers for external tools:
44//!
45//! ```rust,ignore
46//! use adk_tool::McpToolset;
47//! use rmcp::{ServiceExt, transport::TokioChildProcess};
48//!
49//! let client = ().serve(TokioChildProcess::new(
50//! Command::new("npx")
51//! .arg("-y")
52//! .arg("@modelcontextprotocol/server-filesystem")
53//! .arg("/path/to/files")
54//! )?).await?;
55//!
56//! let toolset = McpToolset::new(client);
57//! ```
58
59mod agent_tool;
60pub mod builtin;
61mod function_tool;
62pub mod mcp;
63pub mod toolset;
64
65pub use adk_core::{Tool, ToolContext, Toolset};
66pub use agent_tool::{AgentTool, AgentToolConfig};
67pub use builtin::{ExitLoopTool, GoogleSearchTool, LoadArtifactsTool};
68pub use function_tool::FunctionTool;
69pub use mcp::McpToolset;
70pub use toolset::{string_predicate, BasicToolset};