pub struct ToolMetadata {
pub name: String,
pub description: String,
pub parameters: Vec<ToolParameter>,
pub protocol_metadata: HashMap<String, Value>,
}Expand description
Metadata about a tool
Fields§
§name: StringTool name.
description: StringHuman-readable description.
parameters: Vec<ToolParameter>Parameter schema entries.
protocol_metadata: HashMap<String, Value>Additional metadata specific to the protocol
Implementations§
Source§impl ToolMetadata
impl ToolMetadata
Sourcepub fn new(name: impl Into<String>, description: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, description: impl Into<String>) -> Self
Create metadata with the supplied identifier and description.
Sourcepub fn with_parameter(self, param: ToolParameter) -> Self
pub fn with_parameter(self, param: ToolParameter) -> Self
Append a parameter definition to the tool metadata.
Sourcepub fn with_protocol_metadata(
self,
key: impl Into<String>,
value: Value,
) -> Self
pub fn with_protocol_metadata( self, key: impl Into<String>, value: Value, ) -> Self
Add protocol specific metadata (e.g. MCP capability flags).
Sourcepub fn to_tool_definition(&self) -> ToolDefinition
pub fn to_tool_definition(&self) -> ToolDefinition
Builds a ToolDefinition (JSON Schema) from this metadata.
The resulting ToolDefinition is ready to be passed to
ClientWrapper::send_message
as part of the tools slice. Parameters marked required are collected into the
JSON Schema "required" array automatically.
§Example
use cloudllm::tool_protocol::{ToolMetadata, ToolParameter, ToolParameterType};
let meta = ToolMetadata::new("calculator", "Evaluates a math expression")
.with_parameter(
ToolParameter::new("expression", ToolParameterType::String)
.with_description("The expression to evaluate")
.required(),
);
let def = meta.to_tool_definition();
assert_eq!(def.name, "calculator");
let schema = &def.parameters_schema;
assert_eq!(schema["type"], "object");
assert!(schema["properties"]["expression"].is_object());Trait Implementations§
Source§impl Clone for ToolMetadata
impl Clone for ToolMetadata
Source§fn clone(&self) -> ToolMetadata
fn clone(&self) -> ToolMetadata
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolMetadata
impl Debug for ToolMetadata
Source§impl<'de> Deserialize<'de> for ToolMetadata
impl<'de> Deserialize<'de> for ToolMetadata
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ToolMetadata
impl RefUnwindSafe for ToolMetadata
impl Send for ToolMetadata
impl Sync for ToolMetadata
impl Unpin for ToolMetadata
impl UnsafeUnpin for ToolMetadata
impl UnwindSafe for ToolMetadata
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