pub struct Tool {
pub info: ToolInfo,
pub handler: Box<dyn ToolHandler>,
pub enabled: bool,
pub validator: Option<ParameterValidator>,
pub improved_metadata: ImprovedToolMetadata,
}Expand description
A registered tool with its handler, validation, and improved metadata
Fields§
§info: ToolInfoInformation about the tool
handler: Box<dyn ToolHandler>Handler that implements the tool’s functionality
enabled: boolWhether the tool is currently enabled
validator: Option<ParameterValidator>Parameter validator for input validation
improved_metadata: ImprovedToolMetadataimproved metadata for tool behavior, categorization, and performance
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn new<H>(
name: String,
description: Option<String>,
input_schema: Value,
handler: H,
) -> Selfwhere
H: ToolHandler + 'static,
pub fn new<H>(
name: String,
description: Option<String>,
input_schema: Value,
handler: H,
) -> Selfwhere
H: ToolHandler + 'static,
Create a new tool with the given information and handler
§Arguments
name- Name of the tooldescription- Optional description of the toolinput_schema- JSON schema describing the input parametershandler- Implementation of the tool’s functionality
Sourcepub fn with_validation<H>(
name: String,
description: Option<String>,
input_schema: Value,
handler: H,
validation_config: ValidationConfig,
) -> Selfwhere
H: ToolHandler + 'static,
pub fn with_validation<H>(
name: String,
description: Option<String>,
input_schema: Value,
handler: H,
validation_config: ValidationConfig,
) -> Selfwhere
H: ToolHandler + 'static,
Create a new tool with custom validation configuration
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the tool is enabled
Sourcepub async fn call_unchecked(
&self,
arguments: HashMap<String, Value>,
) -> McpResult<ToolResult>
pub async fn call_unchecked( &self, arguments: HashMap<String, Value>, ) -> McpResult<ToolResult>
Execute the tool without validation or performance tracking (for specialized use cases)
Sourcepub fn validate_parameters(
&self,
arguments: &mut HashMap<String, Value>,
) -> McpResult<()>
pub fn validate_parameters( &self, arguments: &mut HashMap<String, Value>, ) -> McpResult<()>
Validate parameters without executing the tool
Sourcepub fn set_behavior_hints(&mut self, hints: ToolBehaviorHints)
pub fn set_behavior_hints(&mut self, hints: ToolBehaviorHints)
Set behavior hints for the tool
Sourcepub fn behavior_hints(&self) -> &ToolBehaviorHints
pub fn behavior_hints(&self) -> &ToolBehaviorHints
Get behavior hints for the tool
Sourcepub fn set_category(&mut self, category: ToolCategory)
pub fn set_category(&mut self, category: ToolCategory)
Set category for the tool
Sourcepub fn category(&self) -> Option<&ToolCategory>
pub fn category(&self) -> Option<&ToolCategory>
Get category for the tool
Sourcepub fn set_version(&mut self, version: String)
pub fn set_version(&mut self, version: String)
Set version for the tool
Set author for the tool
Get author of the tool
Sourcepub fn deprecate(&mut self, deprecation: ToolDeprecation)
pub fn deprecate(&mut self, deprecation: ToolDeprecation)
Mark tool as deprecated
Sourcepub fn is_deprecated(&self) -> bool
pub fn is_deprecated(&self) -> bool
Check if tool is deprecated
Sourcepub fn deprecation_warning(&self) -> Option<String>
pub fn deprecation_warning(&self) -> Option<String>
Get deprecation warning if tool is deprecated
Sourcepub fn performance_metrics(&self) -> ToolPerformanceMetrics
pub fn performance_metrics(&self) -> ToolPerformanceMetrics
Get performance metrics for the tool
Sourcepub fn add_custom_metadata(&mut self, key: String, value: Value)
pub fn add_custom_metadata(&mut self, key: String, value: Value)
Add custom metadata field
Sourcepub fn get_custom_metadata(&self, key: &str) -> Option<&Value>
pub fn get_custom_metadata(&self, key: &str) -> Option<&Value>
Get custom metadata field
Sourcepub fn matches_category_filter(&self, filter: &CategoryFilter) -> bool
pub fn matches_category_filter(&self, filter: &CategoryFilter) -> bool
Check if tool matches a category filter
Sourcepub fn is_cacheable(&self) -> bool
pub fn is_cacheable(&self) -> bool
Check if tool is suitable for caching based on behavior hints
Sourcepub fn is_destructive(&self) -> bool
pub fn is_destructive(&self) -> bool
Check if tool is destructive
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Check if tool is read-only
Sourcepub fn is_idempotent(&self) -> bool
pub fn is_idempotent(&self) -> bool
Check if tool is idempotent
Sourcepub fn requires_auth(&self) -> bool
pub fn requires_auth(&self) -> bool
Check if tool requires authentication
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Tool
impl !UnwindSafe for Tool
impl Freeze for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnsafeUnpin for Tool
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].