lean_ctx/tools/registered/
ctx_provider.rs1use rmcp::model::Tool;
2use rmcp::ErrorData;
3use serde_json::{json, Map, Value};
4
5use crate::server::tool_trait::{McpTool, ToolContext, ToolOutput};
6use crate::tool_defs::tool_def;
7
8pub struct CtxProviderTool;
9
10impl McpTool for CtxProviderTool {
11 fn name(&self) -> &'static str {
12 "ctx_provider"
13 }
14
15 fn tool_def(&self) -> Tool {
16 tool_def(
17 "ctx_provider",
18 "External context providers (GitHub, GitLab, Jira, Postgres, MCP, custom REST).",
19 json!({
20 "type": "object",
21 "properties": {
22 "action": {
23 "type": "string",
24 "description": "discover|list|status|refresh|configure|query|mcp_resources|gitlab_issues|gitlab_issue|gitlab_mrs|gitlab_pipelines"
25 },
26 "provider": {
27 "type": "string",
28 "description": "Provider ID (github|gitlab|jira|mcp:<name>). Required for query"
29 },
30 "resource": {
31 "type": "string",
32 "description": "query: e.g. issues, pull_requests. configure: paths|template|show"
33 },
34 "mode": { "type": "string", "description": "query output: compact|chunks" },
35 "state": { "type": "string", "description": "open|closed|merged|all" },
36 "labels": { "type": "string", "description": "Comma-separated label filter" },
37 "iid": { "type": "integer", "description": "Issue/MR IID" },
38 "status": { "type": "string", "description": "Pipeline status filter" },
39 "limit": { "type": "integer", "description": "Max results (default 20)" }
40 },
41 "required": ["action"]
42 }),
43 )
44 }
45
46 fn handle(
47 &self,
48 args: &Map<String, Value>,
49 ctx: &ToolContext,
50 ) -> Result<ToolOutput, ErrorData> {
51 let result = crate::tools::ctx_provider::handle(args, ctx);
52 Ok(ToolOutput::simple(result))
53 }
54}