Skip to main content

lean_ctx/tools/registered/
ctx_plugins.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 CtxPluginsTool;
9
10impl McpTool for CtxPluginsTool {
11    fn name(&self) -> &'static str {
12        "ctx_plugins"
13    }
14
15    fn tool_def(&self) -> Tool {
16        tool_def(
17            "ctx_plugins",
18            "Plugin management. Actions: list (show installed plugins), enable (activate a plugin), disable (deactivate a plugin), info (show plugin details), hooks (list available hook points).",
19            json!({
20                "type": "object",
21                "properties": {
22                    "action": {
23                        "type": "string",
24                        "enum": ["list", "enable", "disable", "info", "hooks"],
25                        "description": "Plugin action to perform"
26                    },
27                    "name": {
28                        "type": "string",
29                        "description": "Plugin name (required for enable, disable, info)"
30                    }
31                },
32                "required": ["action"]
33            }),
34        )
35    }
36
37    fn handle(
38        &self,
39        args: &Map<String, Value>,
40        _ctx: &ToolContext,
41    ) -> Result<ToolOutput, ErrorData> {
42        let action = get_str(args, "action").unwrap_or_default();
43        let name = get_str(args, "name");
44
45        let result = crate::tools::ctx_plugins::handle(&action, name.as_deref());
46        Ok(ToolOutput::simple(result))
47    }
48}