1use async_trait::async_trait;
4use serde_json::{json, Value};
5
6use crate::protocol::CallToolResult;
7use crate::tool::{Context, Tool};
8
9pub struct ListRoutes;
10
11#[async_trait]
12impl Tool for ListRoutes {
13 fn name(&self) -> &'static str {
14 "list-routes"
15 }
16 fn description(&self) -> &'static str {
17 "List every HTTP route registered by the application — method, path, and any named middleware. Use this to discover the app's URL surface."
18 }
19 fn input_schema(&self) -> Value {
20 json!({ "type": "object", "properties": {} })
21 }
22
23 async fn call(&self, ctx: &Context, _args: Value) -> CallToolResult {
24 let routes: Vec<Value> = ctx
25 .routes
26 .iter()
27 .map(|r| {
28 json!({
29 "method": r.method.to_string(),
30 "path": r.path,
31 "middleware": r.middleware,
32 })
33 })
34 .collect();
35 CallToolResult::json(&json!({
36 "count": routes.len(),
37 "routes": routes,
38 }))
39 }
40}