mcprotocol_rs/client_features/
roots.rs

1use async_trait::async_trait;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5use crate::Result;
6
7/// Represents a root directory for context
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Root {
10    /// Path to the root directory
11    pub path: String,
12    /// Optional name for the root
13    pub name: Option<String>,
14    /// Optional pattern for files to include
15    pub include_pattern: Option<String>,
16    /// Optional pattern for files to exclude
17    pub exclude_pattern: Option<String>,
18}
19
20/// Root directory manager trait
21#[async_trait]
22pub trait RootManager: Send + Sync {
23    /// Lists all registered roots
24    fn list_roots(&self) -> Vec<Root>;
25
26    /// Adds a new root directory
27    fn add_root(&mut self, root: Root) -> Result<()>;
28
29    /// Removes a root directory
30    fn remove_root(&mut self, path: &str) -> Result<()>;
31
32    /// Gets context from a specific path within roots
33    async fn get_context(&self, path: &str) -> Result<Value>;
34}