pub struct Tool {
pub name: PrimitiveId,
pub title: Option<String>,
pub description: Option<String>,
pub input_schema: JsonObject,
pub output_schema: Option<JsonObject>,
pub annotations: Option<ToolAnnotations>,
pub icons: Option<Vec<ResourceIcon>>,
pub extensions: Extensions,
}Expand description
A tool a client can call.
name and inputSchema are required by every revision including
2026-07-28; everything else was added later and is None for a tool
authored against 2024-11-05.
Fields§
§name: PrimitiveIdname. Required by every revision.
title: Option<String>title. 2026-07-28.
description: Option<String>description. Every revision.
input_schema: JsonObjectinputSchema. Required by every revision, and a JSON Schema object.
Stored as the original text, validated once. See the module docs.
output_schema: Option<JsonObject>outputSchema. 2025-06-18.
annotations: Option<ToolAnnotations>annotations. Typed in 2025-03-26; untyped in nothing — the field
itself first appears there.
icons: Option<Vec<ResourceIcon>>icons. 2026-07-28.
extensions: Extensions_meta and any field a later revision adds.
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn new(
name: impl Into<PrimitiveId>,
input_schema: &str,
) -> Result<Self, JsonObjectError>
pub fn new( name: impl Into<PrimitiveId>, input_schema: &str, ) -> Result<Self, JsonObjectError>
A tool with a name and its input schema, and nothing else.
§Errors
Returns the JsonObject
from parsing input_schema, which is the only fallible step: the schema
is validated here, once, so nothing downstream has to.
Sourcepub fn with_output_schema(self, schema: &str) -> Result<Self, JsonObjectError>
pub fn with_output_schema(self, schema: &str) -> Result<Self, JsonObjectError>
An output schema, which makes the feature ToolStructuredOutput
(2025-06-18) a requirement of this tool.
§Errors
Propagates the parse failure for schema.