Skip to main content

Tool

Struct Tool 

Source
pub struct Tool {
    pub active: bool,
    pub name: String,
    pub description: String,
    pub params: Vec<ToolParam>,
    pub handler: ToolHandler,
}
Expand description

A tool definition

This represents a single tool with its metadata and handler function.

Fields§

§active: bool§name: String§description: String§params: Vec<ToolParam>§handler: ToolHandler

Implementations§

Source§

impl Tool

Source

pub fn builder(name: &str, description: &str, active: bool) -> ToolBuilder

Create a new tool definition with a builder

§Example
Tool::new("get_price", "Get the price of a product")
    .param_i64("product_id", "The product ID", true)
    .handler(handle_get_price)
Source

pub fn to_json_schema(&self) -> Value

Convert tool definition to JSON Schema format

Returns a JSON object compatible with MCP protocol:

{
  "name": "tool_name",
  "description": "Tool description",
  "inputSchema": {
    "type": "object",
    "properties": { ... },
    "required": [ ... ]
  }
}

Auto Trait Implementations§

§

impl Freeze for Tool

§

impl RefUnwindSafe for Tool

§

impl Send for Tool

§

impl Sync for Tool

§

impl Unpin for Tool

§

impl UnsafeUnpin for Tool

§

impl UnwindSafe for Tool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.