Skip to main content

AbstractToolset

Trait AbstractToolset 

Source
pub trait AbstractToolset<Deps = ()>: Send + Sync {
    // Required methods
    fn id(&self) -> Option<&str>;
    fn get_tools<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 RunContext<Deps>,
    ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, ToolsetTool>, ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: Value,
        ctx: &'life2 RunContext<Deps>,
        tool: &'life3 ToolsetTool,
    ) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn label(&self) -> String { ... }
    fn type_name(&self) -> &'static str { ... }
    fn tool_name_conflict_hint(&self) -> String { ... }
    fn enter<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn exit<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Abstract toolset trait - collection of tools with shared management.

Toolsets group related tools together and can provide:

  • Shared lifecycle management (enter/exit)
  • Common configuration
  • Tool filtering and transformation

§Type Parameters

  • Deps: The type of dependencies available to tools.

Required Methods§

Source

fn id(&self) -> Option<&str>

Unique identifier for this toolset.

Source

fn get_tools<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 RunContext<Deps>, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, ToolsetTool>, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get all available tools.

Returns a map of tool names to their definitions.

Source

fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, name: &'life1 str, args: Value, ctx: &'life2 RunContext<Deps>, tool: &'life3 ToolsetTool, ) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Call a tool by name.

Provided Methods§

Source

fn label(&self) -> String

Human-readable label for error messages.

Source

fn type_name(&self) -> &'static str

Type name for debugging.

Source

fn tool_name_conflict_hint(&self) -> String

Hint for resolving name conflicts.

Source

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

Enter context (for resource setup).

Called before the toolset is used. Override to set up resources.

Source

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

Exit context (for cleanup).

Called when done using the toolset. Override to clean up resources.

Implementations on Foreign Types§

Source§

impl<T, Deps> AbstractToolset<Deps> for OutputToolset<T, Deps>
where T: DeserializeOwned + Serialize + Send + Sync + 'static, Deps: Send + Sync + 'static,

Source§

fn id(&self) -> Option<&str>

Source§

fn type_name(&self) -> &'static str

Source§

fn get_tools<'life0, 'life1, 'async_trait>( &'life0 self, _ctx: &'life1 RunContext<Deps>, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, ToolsetTool>, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, OutputToolset<T, Deps>: 'async_trait,

Source§

fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, name: &'life1 str, args: Value, _ctx: &'life2 RunContext<Deps>, _tool: &'life3 ToolsetTool, ) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, OutputToolset<T, Deps>: 'async_trait,

Implementors§

Source§

impl<Deps> AbstractToolset<Deps> for CombinedToolset<Deps>
where Deps: Send + Sync + 'static,

Source§

impl<Deps> AbstractToolset<Deps> for DynamicToolset<Deps>
where Deps: Send + Sync + 'static,

Source§

impl<Deps> AbstractToolset<Deps> for ExternalToolset<Deps>
where Deps: Send + Sync,

Source§

impl<Deps> AbstractToolset<Deps> for FunctionToolset<Deps>
where Deps: Send + Sync + 'static,

Source§

impl<Deps> AbstractToolset<Deps> for McpToolset<Deps>
where Deps: Send + Sync + 'static,

Source§

impl<T, Deps> AbstractToolset<Deps> for ApprovalRequiredToolset<T, Deps>
where T: AbstractToolset<Deps>, Deps: Send + Sync,

Source§

impl<T, Deps> AbstractToolset<Deps> for PrefixedToolset<T, Deps>
where T: AbstractToolset<Deps>, Deps: Send + Sync,

Source§

impl<T, Deps> AbstractToolset<Deps> for RenamedToolset<T, Deps>
where T: AbstractToolset<Deps>, Deps: Send + Sync,

Source§

impl<T, Deps> AbstractToolset<Deps> for WrapperToolset<T, Deps>
where T: AbstractToolset<Deps>, Deps: Send + Sync,

Source§

impl<T, F, Deps> AbstractToolset<Deps> for FilteredToolset<T, F, Deps>
where T: AbstractToolset<Deps>, F: Fn(&RunContext<Deps>, &ToolDefinition) -> bool + Send + Sync, Deps: Send + Sync,

Source§

impl<T, F, Deps> AbstractToolset<Deps> for PreparedToolset<T, F, Deps>
where T: AbstractToolset<Deps>, F: Fn(&RunContext<Deps>, Vec<ToolDefinition>) -> Option<Vec<ToolDefinition>> + Send + Sync, Deps: Send + Sync,