Skip to main content

ToolPlugin

Trait ToolPlugin 

Source
pub trait ToolPlugin: Send + Sync {
    // Required methods
    fn metadata(&self) -> PluginMetadata;
    fn tool_definition(&self) -> Tool;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        arguments: Value,
    ) -> Pin<Box<dyn Future<Output = McpResult<ToolResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn initialize<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn shutdown<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn configure<'life0, 'async_trait>(
        &'life0 mut self,
        _config: Value,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Core trait that all tool plugins must implement

Required Methods§

Source

fn metadata(&self) -> PluginMetadata

Get plugin metadata

Source

fn tool_definition(&self) -> Tool

Get tool definition

Source

fn execute<'life0, 'async_trait>( &'life0 self, arguments: Value, ) -> Pin<Box<dyn Future<Output = McpResult<ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the tool with given arguments

Source

fn as_any(&self) -> &dyn Any

Get plugin as Any for downcasting

Provided Methods§

Source

fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize the plugin (called once after loading)

Source

fn shutdown<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shutdown the plugin (called before unloading)

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the plugin is healthy

Source

fn configure<'life0, 'async_trait>( &'life0 mut self, _config: Value, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle configuration updates

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§