Skip to main content

DynamicToolSource

Trait DynamicToolSource 

Source
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, 'async_trait>(
        &'life0 self,
        call: &'life1 ToolCallContext,
        control: &'life2 CallControl,
    ) -> Pin<Box<dyn Future<Output = Result<ToolResultPayload, ToolExecutionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn version(&self) -> u64 { ... }
    fn invoke_with_store<'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 { ... }
}
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§

Source

fn id(&self) -> &str

Stable catalog identity — also the dispatch namespace key.

Source

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. The reference executor propagates refresh errors and does not substitute an old listing or skip the source. Existing successful bindings retain the targets they already acquired.

Source

fn invoke<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, call: &'life1 ToolCallContext, control: &'life2 CallControl, ) -> Pin<Box<dyn Future<Output = Result<ToolResultPayload, ToolExecutionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: '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). Sources return the recorded result only — handling UnknownOutcome belongs to the execution consumer, not source vocabulary.

Provided Methods§

Source

fn version(&self) -> u64

Change signal for executor-side caching: bump whenever the tool listing may have changed (e.g. MCP tools/list_changed). 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.

Source

fn invoke_with_store<'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 with the host’s artifact store available for media ingest: a source whose tools produce images can persist the bytes via store and attach crate::context::block::MediaRefs to the result’s ToolResultPayload.media instead of degrading them to text. Additive with a delegating default, so sources that never produce media keep their existing invoke only.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§