lean_ctx/tools/registered/
ctx_provider.rs1use rmcp::ErrorData;
2use rmcp::model::Tool;
3use serde_json::{Map, Value, json};
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 "Query GitHub, GitLab, Jira, Postgres, MCP bridges, custom REST.\n\
19 WORKFLOW: action=list first to discover configured providers.\n\
20 ANTIPATTERN: not for file content — use ctx_compose/ctx_read instead.\n\
21 provider=id (github|gitlab|jira|mcp:<name>); resource=issues|pull_requests.\n\
22 Data flows through consolidation pipeline; results searchable via ctx_semantic_search.",
23 json!({
24 "type": "object",
25 "properties": {
26 "action": {
27 "type": "string",
28 "description": "discover|list|status|refresh|configure|query|mcp_resources|gitlab_issues|gitlab_issue|gitlab_mrs|gitlab_pipelines"
29 },
30 "provider": {
31 "type": "string",
32 "description": "github|gitlab|jira|mcp:<name>"
33 },
34 "resource": {
35 "type": "string",
36 "description": "issues|pull_requests|paths|template|show"
37 },
38 "mode": { "type": "string", "description": "compact|chunks" },
39 "state": { "type": "string", "description": "open|closed|merged|all" },
40 "labels": { "type": "string", "description": "Comma-separated labels" },
41 "iid": { "type": "integer", "description": "Issue/MR IID" },
42 "status": { "type": "string", "description": "Pipeline status filter" },
43 "limit": { "type": "integer", "description": "Max results" }
44 },
45 "required": ["action"]
46 }),
47 )
48 }
49
50 fn handle(
51 &self,
52 args: &Map<String, Value>,
53 ctx: &ToolContext,
54 ) -> Result<ToolOutput, ErrorData> {
55 let result = crate::tools::ctx_provider::handle(args, ctx);
56 Ok(ToolOutput::simple(result))
57 }
58}