codeprism_mcp/tools/core/
repository.rs1use crate::tools_legacy::{CallToolParams, CallToolResult, Tool, ToolContent};
4use crate::CodePrismMcpServer;
5use anyhow::Result;
6pub fn list_tools() -> Vec<Tool> {
10 vec![Tool {
11 name: "repository_stats".to_string(),
12 title: Some("Repository Statistics".to_string()),
13 description: "Get comprehensive statistics about the repository".to_string(),
14 input_schema: serde_json::json!({
15 "type": "object",
16 "properties": {}
17 }),
18 }]
19}
20
21pub async fn call_tool(
23 server: &CodePrismMcpServer,
24 params: &CallToolParams,
25) -> Result<CallToolResult> {
26 match params.name.as_str() {
27 "repository_stats" => repository_stats(server).await,
28 _ => Err(anyhow::anyhow!("Unknown repository tool: {}", params.name)),
29 }
30}
31
32async fn repository_stats(server: &CodePrismMcpServer) -> Result<CallToolResult> {
34 let result = if let Some(repo_path) = server.repository_path() {
35 let file_count = server
36 .scanner()
37 .discover_files(repo_path)
38 .map(|files| files.len())
39 .unwrap_or(0);
40
41 let graph_stats = server.graph_store().get_stats();
42
43 serde_json::json!({
44 "repository_path": repo_path.display().to_string(),
45 "total_files": file_count,
46 "total_nodes": graph_stats.total_nodes,
47 "total_edges": graph_stats.total_edges,
48 "nodes_by_kind": graph_stats.nodes_by_kind,
49 "status": "active"
50 })
51 } else {
52 serde_json::json!({
53 "error": "No repository initialized"
54 })
55 };
56
57 Ok(CallToolResult {
58 content: vec![ToolContent::Text {
59 text: serde_json::to_string_pretty(&result)?,
60 }],
61 is_error: Some(false),
62 })
63}