ToolHandler

Trait ToolHandler 

Source
pub trait ToolHandler: Send + Sync {
    // Required methods
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        request: CallToolRequest,
        ctx: RequestContext,
    ) -> Pin<Box<dyn Future<Output = ServerResult<CallToolResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn tool_definition(&self) -> Tool;

    // Provided methods
    fn validate_input(&self, _input: &Value) -> ServerResult<()> { ... }
    fn allowed_roles(&self) -> Option<&[String]> { ... }
}
Expand description

Tool handler trait for processing tool calls

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, request: CallToolRequest, ctx: RequestContext, ) -> Pin<Box<dyn Future<Output = ServerResult<CallToolResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a tool call request

Source

fn tool_definition(&self) -> Tool

Get the tool definition

Provided Methods§

Source

fn validate_input(&self, _input: &Value) -> ServerResult<()>

Validate tool input (optional, default implementation allows all)

Source

fn allowed_roles(&self) -> Option<&[String]>

Allowed roles for this tool (RBAC). None means unrestricted.

Implementors§