pub trait DynamicToolSource: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn invoke<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
call: &'life1 ToolCallContext,
control: &'life2 CallControl,
store: Option<&'life3 dyn ArtifactStore>,
) -> Pin<Box<dyn Future<Output = Result<ToolResultPayload, ToolExecutionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided methods
fn version(&self) -> u64 { ... }
fn describe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDescription>, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
One external tool catalog. Implementors own their connection, their
naming (see the mcp_{server_id}_{tool} namespace convention in
causa-extension), and their change notifications.
Required Methods§
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The current tool listing. Failure means acquisition failed, not an empty catalog.
Sourcefn invoke<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
call: &'life1 ToolCallContext,
control: &'life2 CallControl,
store: Option<&'life3 dyn ArtifactStore>,
) -> Pin<Box<dyn Future<Output = Result<ToolResultPayload, ToolExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn invoke<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
call: &'life1 ToolCallContext,
control: &'life2 CallControl,
store: Option<&'life3 dyn ArtifactStore>,
) -> Pin<Box<dyn Future<Output = Result<ToolResultPayload, ToolExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Execute one call against the catalog. call.input.tool_name arrives in
the source’s namespace; implementors de-namespace it (and reject
names outside their namespace). A source that can report the terminal
status returns Ok with it, including TimedOut or Cancelled
carrying any partial output; the timeout and cancellation errors below
mean no result was observed, and the bridge records UnknownOutcome
for them. A source must not synthesize UnknownOutcome itself: the
bridge passes an Ok result through unchanged, so a source without a
result returns an error and lets the bridge map it.
store is the host’s artifact store when one is configured. A source
whose tools produce images persists the bytes there and attaches
crate::context::block::MediaRefs to the result’s media instead of
degrading them to text; a source that never produces media ignores it.
Provided Methods§
Sourcefn version(&self) -> u64
fn version(&self) -> u64
Change signal for executor-side caching: bump whenever the tool
listing may have changed (e.g. MCP tools/list_changed), including a
change in the tools’ declared hints alone. Consumers
may reuse a listing while the observed version remains unchanged.
This signal does not make version/list reads an atomic snapshot or
replace an invocation binding to concrete targets.
Sourcefn describe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDescription>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn describe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDescription>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The current tool listing with each tool’s declared hints. The
reference executor binds from this method, so a tool’s definition and
hints come from the same listing. The default calls
DynamicToolSource::list and declares no hints; a source whose
catalog carries hints, such as MCP tool annotations, overrides it.
Failure means acquisition failed, not an empty catalog. The reference executor propagates refresh errors and does not substitute an old listing or skip the source. Existing successful bindings retain the targets and hints they already acquired.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".