pub struct ToolRegistry { /* private fields */ }Expand description
Registry for managing tools.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register_provider<P: ToolProvider>(&mut self, provider: P)
pub fn register_provider<P: ToolProvider>(&mut self, provider: P)
Registers multiple tools from a provider.
Sourcepub fn definitions(&self) -> Vec<McpToolDefinition>
pub fn definitions(&self) -> Vec<McpToolDefinition>
Returns all tool definitions (cached).
Uses an Arc-wrapped cache to minimize cloning overhead. Returns a clone of the Arc, so iterating is efficient.
Sourcepub fn definitions_iter(&self) -> impl Iterator<Item = McpToolDefinition> + '_
pub fn definitions_iter(&self) -> impl Iterator<Item = McpToolDefinition> + '_
Returns an iterator over tool definitions without cloning.
More efficient than definitions() when you only need to iterate.
Sourcepub fn definitions_uncached(&self) -> Vec<McpToolDefinition>
pub fn definitions_uncached(&self) -> Vec<McpToolDefinition>
Returns all tool definitions without caching (for cases where fresh data is needed).
Sourcepub fn invalidate_cache(&self)
pub fn invalidate_cache(&self)
Invalidates the definitions cache.
Sourcepub async fn call(&self, name: &str, args: Value) -> ToolCallResult
pub async fn call(&self, name: &str, args: Value) -> ToolCallResult
Calls a tool by name with the given arguments.
Trait Implementations§
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§fn default() -> ToolRegistry
fn default() -> ToolRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ToolRegistry
impl !RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl !UnwindSafe for ToolRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more