Expand description
Descry Tool Core - Modern async-first tool framework
Provides zero-cost, compile-time tool registration with modern Rust best practices.
§Features
- Single async Tool trait - No SyncTool/AsyncTool separation
- Arc
- No borrow checker hell, works across await points - Compile-time registration - Using
inventoryfor zero startup cost - Thread-local schema cache - Generated once per type
- Thread-safe -
DashMapfor concurrent extensions - Error chaining -
thiserrorwith#[source]support - Multi-protocol adapters - MCP, OpenAI, Anthropic built-in
- Tower Service integration - Middleware ecosystem support (optional)
§Quick Start
ⓘ
use descry_tool_core::{Tool, ToolContext, ToolError};
use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
use std::sync::Arc;
#[derive(Deserialize, JsonSchema)]
struct AddParams {
a: i32,
b: i32,
}
#[derive(Serialize, JsonSchema)]
struct AddOutput {
result: i32,
}
struct AddTool;
impl Tool for AddTool {
type Params = AddParams;
type Output = AddOutput;
const NAME: &'static str = "add";
const DESCRIPTION: &'static str = "Add two numbers";
async fn call(
ctx: Arc<ToolContext>,
params: Self::Params,
) -> Result<Self::Output, ToolError> {
Ok(AddOutput {
result: params.a + params.b,
})
}
}Re-exports§
pub use context::Meta;pub use context::ToolContext;pub use error::ToolError;pub use registry::all_tools;pub use registry::call_tool;pub use registry::find_tool;pub use registry::get_tool_examples;pub use registry::get_tool_schema;pub use registry::tool_count;pub use registry::tool_exists;pub use registry::tool_names;pub use registry::ToolMeta;pub use tool::HasAnnotations;pub use tool::Tool;pub use types::JsonObject;pub use adapters::AnthropicAdapter;pub use adapters::McpAdapter;pub use adapters::OpenAiAdapter;pub use adapters::ToolAdapter;
Modules§
- adapters
- Protocol adapters for different LLM platforms
- context
- Tool execution context
- error
- Tool error types
- registry
- Compile-time tool registry using inventory
- tool
- Core tool trait
- types
- Basic type definitions
Traits§
- Json
Schema - A type which can be described as a JSON Schema document.
Derive Macros§
- Json
Schema - Derive macro for
JsonSchematrait.