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, '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 method
    fn version(&self) -> u64 { ... }
}
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, '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). Sources return the recorded result only — handling UnknownOutcome belongs to the execution consumer, not source vocabulary.

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§

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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§