pub struct Tool {
pub name: Cow<'static, str>,
pub title: Option<String>,
pub description: Option<Cow<'static, str>>,
pub input_schema: Arc<Map<String, Value>>,
pub output_schema: Option<Arc<Map<String, Value>>>,
pub annotations: Option<ToolAnnotations>,
pub icons: Option<Vec<Icon>>,
pub meta: Option<Meta>,
}Expand description
A tool that can be used by a model.
Fields§
§name: Cow<'static, str>The name of the tool
title: Option<String>A human-readable title for the tool
description: Option<Cow<'static, str>>A description of what the tool does
input_schema: Arc<Map<String, Value>>A JSON Schema object defining the expected parameters for the tool
output_schema: Option<Arc<Map<String, Value>>>An optional JSON Schema object defining the structure of the tool’s output
annotations: Option<ToolAnnotations>Optional additional tool information.
icons: Option<Vec<Icon>>Optional list of icons for the tool
meta: Option<Meta>Optional additional metadata for this tool
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Tool
pub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Tool
Create a new tool with the given name and description
pub fn annotate(self, annotations: ToolAnnotations) -> Tool
Sourcepub fn with_output_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
pub fn with_output_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
Set the output schema using a type that implements JsonSchema
§Panics
Panics if the generated schema does not have root type “object” as required by MCP specification.
Sourcepub fn with_input_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
pub fn with_input_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
Set the input schema using a type that implements JsonSchema
Sourcepub fn schema_as_json_value(&self) -> Value
pub fn schema_as_json_value(&self) -> Value
Get the schema as json value
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tool
impl<'de> Deserialize<'de> for Tool
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Tool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Tool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Tool
impl Serialize for Tool
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Tool
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
type Error = <Target as OctetsFrom<Source>>::Error
Source§fn try_octets_into(
self,
) -> Result<Target, <Source as OctetsInto<Target>>::Error>
fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>
Performs the conversion.
Source§fn octets_into(self) -> Target
fn octets_into(self) -> Target
Performs an infallible conversion.