Skip to main content

lean_ctx/tools/registered/
ctx_wrapped.rs

1use rmcp::model::Tool;
2use rmcp::ErrorData;
3use serde_json::{json, Map, Value};
4
5use crate::server::tool_trait::{get_str, McpTool, ToolContext, ToolOutput};
6use crate::tool_defs::tool_def;
7
8pub struct CtxWrappedTool;
9
10impl McpTool for CtxWrappedTool {
11    fn name(&self) -> &'static str {
12        "ctx_wrapped"
13    }
14
15    fn tool_def(&self) -> Tool {
16        tool_def(
17            "ctx_wrapped",
18            "Session savings summary report (weekly/monthly/daily).",
19            json!({
20                "type": "object",
21                "properties": {
22                    "period": { "type": "string", "description": "week|month|day" }
23                }
24            }),
25        )
26    }
27
28    fn handle(
29        &self,
30        args: &Map<String, Value>,
31        _ctx: &ToolContext,
32    ) -> Result<ToolOutput, ErrorData> {
33        let period = get_str(args, "period").unwrap_or_else(|| "week".to_string());
34        let result = crate::tools::ctx_wrapped::handle(&period);
35        Ok(ToolOutput {
36            text: result,
37            original_tokens: 0,
38            saved_tokens: 0,
39            mode: Some(period),
40            path: None,
41        })
42    }
43}