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 JsonSchema for Tool
impl JsonSchema for Tool
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§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