pub trait ToolSource: Send + Sync {
// Required methods
fn specs(&self) -> Vec<ToolSpec>;
fn get(&self, name: &ToolName) -> Option<Arc<dyn Tool>>;
// Provided methods
fn drain_catalog_events(&self) -> Vec<ToolCatalogEvent> { ... }
fn prefixed(self, prefix: impl Into<String>) -> Prefixed<Self>
where Self: Sized { ... }
fn filtered<F>(self, predicate: F) -> Filtered<Self, F>
where Self: Sized,
F: Fn(&ToolName) -> bool + Send + Sync + 'static { ... }
fn renamed<I>(self, mapping: I) -> Renamed<Self>
where Self: Sized,
I: IntoIterator<Item = (ToolName, ToolName)> { ... }
}Expand description
Read-side contract for a federated tool catalog.
A BasicToolExecutor composes one or more ToolSources — typically a
frozen ToolRegistry of native tools alongside one or more
CatalogReaders owned by subsystems (MCP server manager, skill watcher,
plugin loader). Each source manages its own lifecycle and concurrency
story; the executor only reads.
Required Methods§
Provided Methods§
Sourcefn drain_catalog_events(&self) -> Vec<ToolCatalogEvent>
fn drain_catalog_events(&self) -> Vec<ToolCatalogEvent>
Drains pending catalog change events. Static sources return an empty list; dynamic sources surface added/removed/changed batches that the loop forwards to the model on the next turn.
Sourcefn prefixed(self, prefix: impl Into<String>) -> Prefixed<Self>where
Self: Sized,
fn prefixed(self, prefix: impl Into<String>) -> Prefixed<Self>where
Self: Sized,
Wraps this source so every advertised tool name is prefixed with
<prefix>_. Useful for mounting the same source under multiple
namespaces, or for avoiding collisions between MCP catalogs.
Lookups strip the prefix before delegating, and the wrapped tool’s
spec() reports the public (prefixed) name so the model and the
tool see consistent names.
To wrap an Arc<dyn ToolSource> instead, use Prefixed::new.
Sourcefn filtered<F>(self, predicate: F) -> Filtered<Self, F>
fn filtered<F>(self, predicate: F) -> Filtered<Self, F>
Wraps this source so only tools whose name passes predicate are
advertised and resolvable. Tools rejected by the predicate are
invisible to the model and return None on lookup.
To wrap an Arc<dyn ToolSource> instead, use Filtered::new.
Sourcefn renamed<I>(self, mapping: I) -> Renamed<Self>
fn renamed<I>(self, mapping: I) -> Renamed<Self>
Wraps this source with a name remapping. Each (original, new) pair
in mapping causes the tool to be advertised as new and resolved
from new back to original on lookup. Tools not in the mapping
pass through unchanged.
To wrap an Arc<dyn ToolSource> instead, use Renamed::new.