pub struct Tool {
pub name: String,
pub title: Option<String>,
pub description: Option<String>,
pub output_schema: Option<Value>,
pub icons: Option<Vec<ToolIcon>>,
pub annotations: Option<ToolAnnotations>,
/* private fields */
}Expand description
A complete tool definition with handler
Fields§
§name: String§title: Option<String>§description: Option<String>§output_schema: Option<Value>§icons: Option<Vec<ToolIcon>>§annotations: Option<ToolAnnotations>Implementations§
Source§impl Tool
impl Tool
Sourcepub fn builder(name: impl Into<String>) -> ToolBuilder
pub fn builder(name: impl Into<String>) -> ToolBuilder
Create a new tool builder
Sourcepub fn definition(&self) -> ToolDefinition
pub fn definition(&self) -> ToolDefinition
Get the tool definition for tools/list
Sourcepub fn call(&self, args: Value) -> BoxFuture<'_, Result<CallToolResult>>
pub fn call(&self, args: Value) -> BoxFuture<'_, Result<CallToolResult>>
Call the tool without context
Sourcepub fn call_with_context(
&self,
ctx: RequestContext,
args: Value,
) -> BoxFuture<'_, Result<CallToolResult>>
pub fn call_with_context( &self, ctx: RequestContext, args: Value, ) -> BoxFuture<'_, Result<CallToolResult>>
Call the tool with request context
Use this when you have a RequestContext available for progress/cancellation.
Sourcepub fn uses_context(&self) -> bool
pub fn uses_context(&self) -> bool
Returns true if this tool uses context
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tool
impl !RefUnwindSafe for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl !UnwindSafe for Tool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more