#[non_exhaustive]pub struct ToolDefinition {
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<MetaObject>,
}Expand description
A tool that can be used by a model.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.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<MetaObject>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
Sourcepub fn new_with_raw<N, S>(
name: N,
description: Option<Cow<'static, str>>,
input_schema: S,
) -> Tool
pub fn new_with_raw<N, S>( name: N, description: Option<Cow<'static, str>>, input_schema: S, ) -> Tool
Create a new tool with just a name and input schema (no description)
Sourcepub fn with_title(self, title: impl Into<String>) -> Tool
pub fn with_title(self, title: impl Into<String>) -> Tool
Set the human-readable title
Sourcepub fn with_raw_output_schema(
self,
output_schema: Arc<Map<String, Value>>,
) -> Tool
pub fn with_raw_output_schema( self, output_schema: Arc<Map<String, Value>>, ) -> Tool
Set the output schema from a raw value
Sourcepub fn with_annotations(self, annotations: ToolAnnotations) -> Tool
pub fn with_annotations(self, annotations: ToolAnnotations) -> Tool
Set the annotations
Sourcepub fn with_icons(self, icons: Vec<Icon>) -> Tool
pub fn with_icons(self, icons: Vec<Icon>) -> Tool
Set the icons
Sourcepub fn with_meta(self, meta: MetaObject) -> Tool
pub fn with_meta(self, meta: MetaObject) -> Tool
Set the metadata
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
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<Input> AsRef<Tool> for McpTypedTool<Input>
impl<Input> AsRef<Tool> for McpTypedTool<Input>
Source§fn as_ref(&self) -> &ToolDefinition
fn as_ref(&self) -> &ToolDefinition
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>,
Source§impl JsonSchema for Tool
impl JsonSchema for Tool
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more