adk-rust-macros 0.4.0

Proc macros for ADK-Rust — #[tool] attribute for zero-boilerplate tool registration
Documentation

adk-macros

Proc macros for ADK-Rust that eliminate tool registration boilerplate.

#[tool]

Turns an async function into a fully-wired [adk_tool::Tool] implementation:

use adk_macros::tool;
use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Deserialize, JsonSchema)]
struct WeatherArgs {
    /// The city to look up
    city: String,
}

/// Get the current weather for a city.
#[tool]
async fn get_weather(args: WeatherArgs) -> Result<serde_json::Value, adk_tool::AdkError> {
    Ok(serde_json::json!({ "temp": 72, "city": args.city }))
}

// This generates a struct `GetWeather` that implements `adk_tool::Tool`.
// Use it like: Arc::new(GetWeather)

The macro:

  • Uses the function's doc comment as the tool description
  • Derives the JSON schema from the argument type via schemars::schema_for!
  • Names the tool after the function (snake_case)
  • Generates a zero-sized struct (PascalCase) implementing Tool