Trait Tool

Source
pub trait Tool: Clone {
    // Required methods
    fn name(&self) -> &'static str;
    fn description(&self) -> &'static str;
    fn input_schema(&self) -> Value;
    fn call(&self, arguments: &Value) -> Result<ToolResult, ToolError>;

    // Provided methods
    fn server_name(&self) -> String { ... }
    fn server_version(&self) -> &'static str { ... }
    fn capabilities(&self) -> Value { ... }
}
Expand description

Trait that all FTL Core tools must implement

This trait defines a single computational tool optimized for WebAssembly performance. FTL Core follows the “1 tool per server” architecture for maximum efficiency.

Required Methods§

Source

fn name(&self) -> &'static str

The name of the tool (used in MCP tool calls)

Source

fn description(&self) -> &'static str

Human-readable description of what the tool does

Source

fn input_schema(&self) -> Value

JSON schema for the tool’s input parameters

Return a JSON object describing the expected input structure. Example:

{
  "type": "object",
  "properties": {
    "text": {
      "type": "string",
      "description": "The text to process"
    }
  },
  "required": ["text"]
}
Source

fn call(&self, arguments: &Value) -> Result<ToolResult, ToolError>

Execute the tool with the provided arguments

This is where your tool’s core logic goes. The arguments are validated against your input schema before this method is called.

Provided Methods§

Source

fn server_name(&self) -> String

Optional: Custom server name (defaults to tool name)

Source

fn server_version(&self) -> &'static str

Optional: Server version (defaults to “0.0.1”)

Source

fn capabilities(&self) -> Value

Optional: Additional server capabilities

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§