use async_trait::async_trait;
use serde_json::{json, Value};
use crate::protocol::CallToolResult;
use crate::tool::{Context, Tool};
pub struct ListModels;
#[async_trait]
impl Tool for ListModels {
fn name(&self) -> &'static str {
"list-models"
}
fn description(&self) -> &'static str {
"List every cast model registered via `#[derive(Model)]`. Returns table name and Rust struct path."
}
async fn call(&self, _ctx: &Context, _args: Value) -> CallToolResult {
let models = cast_core::registered_models();
let payload: Vec<Value> = models
.iter()
.map(|m| {
json!({
"class": m.class,
"table": m.table,
})
})
.collect();
CallToolResult::json(&json!({
"count": payload.len(),
"models": payload,
}))
}
}