claude_agent/types/tool/
definition.rs

1//! Tool definition types.
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct ToolDefinition {
7    pub name: String,
8    pub description: String,
9    pub input_schema: serde_json::Value,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub strict: Option<bool>,
12}
13
14impl ToolDefinition {
15    pub fn new(
16        name: impl Into<String>,
17        description: impl Into<String>,
18        input_schema: serde_json::Value,
19    ) -> Self {
20        Self {
21            name: name.into(),
22            description: description.into(),
23            input_schema,
24            strict: None,
25        }
26    }
27
28    pub fn with_strict(mut self, strict: bool) -> Self {
29        self.strict = Some(strict);
30        self
31    }
32}