rag-server-mcp 2.3.3

Sovereign, high-performance RAG MCP server written in Rust for local code and legal search.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::db::Db;
use std::sync::Arc;
use tokio::sync::Mutex;

pub async fn list_collections(db: &Arc<Mutex<Db>>) -> anyhow::Result<String> {
    let db_guard = db.lock().await;
    // Använd den befintliga metoden `list_collections` (inte `get_collections`)
    let collections = db_guard.list_collections()?;
    if collections.is_empty() {
        return Ok("Inga samlingar än.".to_string());
    }
    let lines: Vec<String> = collections
        .iter()
        .map(|(name, count)| format!("{}: {} dokument", name, count))
        .collect();
    Ok(format!("Databasens samlingar:\n{}", lines.join("\n")))
}