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§
Sourcefn 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 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
Sourcefn tool_definition(&self) -> Tool
fn tool_definition(&self) -> Tool
Get the tool definition
Provided Methods§
Sourcefn validate_input(&self, _input: &Value) -> ServerResult<()>
fn validate_input(&self, _input: &Value) -> ServerResult<()>
Validate tool input (optional, default implementation allows all)
Sourcefn allowed_roles(&self) -> Option<&[String]>
fn allowed_roles(&self) -> Option<&[String]>
Allowed roles for this tool (RBAC). None means unrestricted.