use serde_json::Value;
use crate::types::{ToolError, ToolResult};
pub trait Tool: Clone {
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn input_schema(&self) -> Value;
fn call(&self, arguments: &Value) -> Result<ToolResult, ToolError>;
fn server_name(&self) -> String {
format!("ftl-{}", self.name())
}
fn server_version(&self) -> &'static str {
"0.0.1"
}
fn capabilities(&self) -> Value {
serde_json::json!({
"tools": {}
})
}
}
#[derive(Debug)]
pub struct ToolInfo {
pub name: String,
pub description: String,
pub input_schema: Value,
}
impl<T: Tool> From<&T> for ToolInfo {
fn from(tool: &T) -> Self {
Self {
name: tool.name().to_string(),
description: tool.description().to_string(),
input_schema: tool.input_schema(),
}
}
}