#[non_exhaustive]pub struct Tool {
pub name: Cow<'static, str>,
pub title: Option<String>,
pub description: Option<Cow<'static, str>>,
pub input_schema: Arc<JsonObject>,
pub output_schema: Option<Arc<JsonObject>>,
pub annotations: Option<ToolAnnotations>,
pub execution: Option<ToolExecution>,
pub icons: Option<Vec<Icon>>,
pub meta: Option<Meta>,
}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<JsonObject>A JSON Schema object defining the expected parameters for the tool
output_schema: Option<Arc<JsonObject>>An optional JSON Schema object defining the structure of the tool’s output
annotations: Option<ToolAnnotations>Optional additional tool information.
execution: Option<ToolExecution>Execution-related configuration including task support mode.
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) -> Self
pub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Self
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,
) -> Self
pub fn new_with_raw<N, S>( name: N, description: Option<Cow<'static, str>>, input_schema: S, ) -> Self
Create a new tool with just a name and input schema (no description)
Sourcepub fn with_title(self, title: Option<String>) -> Self
pub fn with_title(self, title: Option<String>) -> Self
Set the human-readable title
Sourcepub fn with_raw_output_schema(
self,
output_schema: Option<Arc<JsonObject>>,
) -> Self
pub fn with_raw_output_schema( self, output_schema: Option<Arc<JsonObject>>, ) -> Self
Set the output schema from a raw value
Sourcepub fn with_annotations(self, annotations: Option<ToolAnnotations>) -> Self
pub fn with_annotations(self, annotations: Option<ToolAnnotations>) -> Self
Set the annotations
Sourcepub fn with_icons(self, icons: Option<Vec<Icon>>) -> Self
pub fn with_icons(self, icons: Option<Vec<Icon>>) -> Self
Set the icons
pub fn annotate(self, annotations: ToolAnnotations) -> Self
Sourcepub fn with_execution(self, execution: Option<ToolExecution>) -> Self
pub fn with_execution(self, execution: Option<ToolExecution>) -> Self
Set the execution configuration for this tool.
Sourcepub fn task_support(&self) -> TaskSupport
pub fn task_support(&self) -> TaskSupport
Returns the task support mode for this tool.
Returns TaskSupport::Forbidden if not explicitly set.
Sourcepub fn with_output_schema<T: JsonSchema + 'static>(self) -> Self
Available on crate feature server only.
pub fn with_output_schema<T: JsonSchema + 'static>(self) -> Self
server only.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: JsonSchema + 'static>(self) -> Self
Available on crate feature server only.
pub fn with_input_schema<T: JsonSchema + 'static>(self) -> Self
server only.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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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