Descry Tool
A modern, async-first Rust framework for building LLM-compatible tools with zero-cost abstractions and compile-time registration.
Features
- Single async Tool trait - No SyncTool/AsyncTool separation
- Arc - No borrow checker hell, works seamlessly across await points
- Derive-first design - One
#[tool]macro generates everything - Thread-safe -
DashMapfor concurrent extensions - Multi-protocol adapters - Built-in MCP, OpenAI, Anthropic support
- Tower Service integration - Middleware ecosystem support (optional)
- Auto-generated schemas - Type-safe JSON Schema with thread-local caching
Installation
Add this to your Cargo.toml:
[]
= "0.2"
= "0.2"
= { = "1", = ["macros", "rt", "rt-multi-thread", "sync"] }
# Optional: for async runtime
= { = "1", = ["macros", "rt", "rt-multi-thread"] }
# Optional: Tower middleware support
= { = "0.2", = ["tower"] }
= "0.5"
= { = "0.6", = ["timeout", "limit"] }
[]
= { = "1", = ["macros", "rt", "rt-multi-thread", "sync"] }
[]
= ["macros"]
= ["dep:tower"]
Quick Start
Define a Tool
use ;
use tool;
use JsonSchema;
use ;
use Arc;
// One macro does it all!
async
Use the Tool
use ;
use Arc;
async
Core Concepts
Tool Trait
The unified Tool trait with async-first design:
Compile-Time Registration
Tools are automatically registered using inventory:
// No manual registration needed!
// The #[tool] macro automatically generates:
//
// inventory::submit! {
// ToolMeta {
// name: "add",
// description: "Add two numbers",
// call: |ctx, params| { /* ... */ },
// schema: || AddTool::schema(),
// examples: || AddTool::EXAMPLES(),
// }
// }
Context System
Thread-safe context with Arc<ToolContext>:
use ToolContext;
use Arc;
let ctx = new;
// Insert extensions
;
ctx.insert;
// Get extensions
let db: = ctx.get.unwrap;
Multi-Protocol Support
Generate tool specifications for different LLM platforms
use ;
// MCP (Model Context Protocol)
let mcp_tools: = all_tools
.map
.collect;
// OpenAI Function Calling
let openai_tools: = all_tools
.map
.collect;
// Anthropic (Claude)
let anthropic_tools: = all_tools
.map
.collect;
Tower Middleware (Optional)
Use Tower middleware for logging, timeouts, rate limiting
use ;
use ;
use ;
use Duration;
let service = new
.layer
.layer
.service;
let response = service.call.await?;
Examples
See descry-tool-core/examples/:
basic.rs- Basic tool definition and usagemacro_example.rs- Using the#[tool]macrocomplete_example.rs- Multiple tools with error handlingmulti_protocol.rs- Multi-protocol adapter usagetower_basic.rs- Tower Service integrationtower_middleware.rs- Tower middleware exampledebug_schema.rs- Schema generation debugging
API Reference
Core Functions
// Get all registered tools
pub async
Project Structure
descry-tool/
├── descry-tool-core/ # Core traits and types
│ ├── src/
│ │ ├── lib.rs # Main exports
│ │ ├── tool.rs # Tool trait
│ │ ├── context.rs # Arc<ToolContext>
│ │ ├── error.rs # ToolError
│ │ ├── registry.rs # inventory registration
│ │ ├── adapters/ # Protocol adapters
│ │ └── tower.rs # Tower Service (optional)
│ └── examples/ # Usage examples
├── descry-tool-macros/ # Procedural macros
│ └── src/
│ └── tool.rs # #[tool] macro implementation
└── README.md