pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn input_schema(&self) -> Value;
fn call<'life0, 'async_trait>(
&'life0 self,
input: ToolInput,
) -> Pin<Box<dyn Future<Output = ToolOutput> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A registered MCP tool. Implementations describe themselves (name,
description, schema) and implement the async call method that
produces an output for the given input.
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Tool name. Exposed to the model as mcp__<server>__<tool>.
'static rather than borrowed from &self: a tool’s identity is
fixed at compile time, and eliding the lifetime here made every
impl in the tree trip clippy::unnecessary_literal_bound.
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
One-line description.
Sourcefn input_schema(&self) -> Value
fn input_schema(&self) -> Value
JSON Schema describing the tool’s arguments.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".