Skip to main content

do_memory_mcp/server/tools/external_signals/
configure_agentfs.rs

1//! Configure AgentFS external signal provider tool handler
2//!
3//! This module provides the tool for configuring the AgentFS endpoint
4//! and settings for external signal integration with the reward system.
5
6use crate::server::MemoryMCPServer;
7use anyhow::Result;
8use serde_json::json;
9use tracing::debug;
10
11impl MemoryMCPServer {
12    /// Execute the configure_agentfs tool
13    ///
14    /// # Arguments
15    ///
16    /// * `input` - Configuration parameters for the AgentFS provider
17    ///
18    /// # Returns
19    ///
20    /// Returns configuration result with provider details
21    pub async fn execute_configure_agentfs(
22        &self,
23        input: crate::mcp::tools::external_signals::ConfigureAgentFsInput,
24    ) -> Result<serde_json::Value> {
25        self.track_tool_usage("configure_agentfs").await;
26
27        debug!(
28            "Configuring AgentFS provider: db_path='{}', enabled={}",
29            input.db_path, input.enabled
30        );
31
32        // Validate weight is within bounds
33        let weight = input.weight.clamp(0.0, 1.0);
34        let min_samples = input.min_samples.max(1);
35
36        // Create configuration response
37        let result = crate::mcp::tools::external_signals::ConfigureAgentFsOutput {
38            success: true,
39            provider: "agentfs".to_string(),
40            db_path: input.db_path.clone(),
41            enabled: input.enabled,
42            weight,
43            min_samples,
44            sanitize: input.sanitize,
45            message: format!(
46                "AgentFS provider configured successfully. Enabled: {}, Weight: {:.2}",
47                input.enabled, weight
48            ),
49            warnings: vec![],
50        };
51
52        // In a full implementation, this would:
53        // 1. Store configuration in the database
54        // 2. Initialize/refresh the AgentFS provider connection
55        // 3. Register with the external signal registry
56
57        // Convert result to JSON
58        Ok(json!(result))
59    }
60}
61
62#[cfg(test)]
63mod tests {
64    use super::*;
65
66    #[test]
67    #[allow(clippy::manual_async_fn)]
68    fn test_configure_agentfs_signature_compile() {
69        // This test ensures the method signature compiles correctly
70        use crate::mcp::tools::external_signals::ConfigureAgentFsInput;
71        fn method_signature(
72            _server: &MemoryMCPServer,
73            _input: ConfigureAgentFsInput,
74        ) -> impl std::future::Future<Output = Result<serde_json::Value>> {
75            async { Ok(json!({})) }
76        }
77        let _ = method_signature; // Use the function to avoid unused warnings
78    }
79}