Skip to main content

ToolCatalog

Trait ToolCatalog 

Source
pub trait ToolCatalog: Send + Sync {
    // Required methods
    fn register_tool<'life0, 'async_trait>(
        &'life0 self,
        registration: ToolRegistration,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn unregister_tool<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_tool(&self, name: &str) -> Option<Arc<dyn Tool>>;
    fn workspace_root(&self) -> PathBuf;
    fn public_tool_names<'life0, 'async_trait>(
        &'life0 self,
        surface: SessionSurface,
        capability_level: CapabilityLevel,
    ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn schema_entries<'life0, 'async_trait>(
        &'life0 self,
        config: SessionToolsConfig,
    ) -> Pin<Box<dyn Future<Output = Vec<ToolSchemaEntry>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn function_declarations<'life0, 'async_trait>(
        &'life0 self,
        config: SessionToolsConfig,
    ) -> Pin<Box<dyn Future<Output = Vec<FunctionDeclaration>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn model_tools<'life0, 'async_trait>(
        &'life0 self,
        config: SessionToolsConfig,
    ) -> Pin<Box<dyn Future<Output = Vec<ToolDefinition>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn resolve_tool_name(&self, name: &str) -> Result<String, ToolCallError>;
}
Expand description

Tool catalog: registration, lookup, and schema access.

The catalog is the source of truth for which tools are available and how to invoke them. It supports dynamic registration (e.g., MCP tools added at runtime) and provides schema information for LLM tool-calling.

Required Methods§

Source

fn register_tool<'life0, 'async_trait>( &'life0 self, registration: ToolRegistration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Register a tool. Replaces any existing registration with the same name.

Source

fn unregister_tool<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unregister a tool by name. Returns true if the tool existed.

Source

fn get_tool(&self, name: &str) -> Option<Arc<dyn Tool>>

Get a tool by name (with hot-cache optimization).

Source

fn workspace_root(&self) -> PathBuf

Get the workspace root path.

Source

fn public_tool_names<'life0, 'async_trait>( &'life0 self, surface: SessionSurface, capability_level: CapabilityLevel, ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List public tool names for a given surface and capability level.

Source

fn schema_entries<'life0, 'async_trait>( &'life0 self, config: SessionToolsConfig, ) -> Pin<Box<dyn Future<Output = Vec<ToolSchemaEntry>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get schema entries for all available tools.

Source

fn function_declarations<'life0, 'async_trait>( &'life0 self, config: SessionToolsConfig, ) -> Pin<Box<dyn Future<Output = Vec<FunctionDeclaration>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get Gemini-style function declarations for tool-calling.

Source

fn model_tools<'life0, 'async_trait>( &'life0 self, config: SessionToolsConfig, ) -> Pin<Box<dyn Future<Output = Vec<ToolDefinition>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get OpenAI/Anthropic-style tool definitions.

Source

fn resolve_tool_name(&self, name: &str) -> Result<String, ToolCallError>

Resolve a public tool name to its canonical registration name.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§