Skip to main content

do_memory_mcp/server/tools/embeddings/
configure.rs

1//! Configure embeddings tool handler for MCP server
2//!
3//! This module provides the tool for configuring semantic embedding
4//! providers for enhanced memory retrieval.
5
6use crate::server::MemoryMCPServer;
7use anyhow::Result;
8use serde_json::json;
9use std::sync::Arc;
10use tracing::debug;
11
12impl MemoryMCPServer {
13    /// Execute the configure_embeddings tool
14    ///
15    /// # Arguments
16    ///
17    /// * `input` - Configuration parameters for the embedding provider
18    ///
19    /// # Returns
20    ///
21    /// Returns configuration result with provider details
22    pub async fn execute_configure_embeddings(
23        &self,
24        input: crate::mcp::tools::embeddings::ConfigureEmbeddingsInput,
25    ) -> Result<serde_json::Value> {
26        self.track_tool_usage("configure_embeddings").await;
27
28        debug!(
29            "Configuring embeddings: provider='{}', model='{:?}'",
30            input.provider, input.model
31        );
32
33        let tool = crate::mcp::tools::embeddings::EmbeddingTools::new(Arc::clone(&self.memory));
34
35        let result = tool.execute_configure_embeddings(input).await?;
36
37        // Convert result to JSON
38        Ok(json!(result))
39    }
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    #[allow(clippy::manual_async_fn)]
48    fn test_configure_embeddings_signature_compile() {
49        // This test ensures the method signature compiles correctly
50        // The actual functionality is tested in the tool implementation tests
51        use crate::mcp::tools::embeddings::ConfigureEmbeddingsInput;
52        fn method_signature(
53            _server: &MemoryMCPServer,
54            _input: ConfigureEmbeddingsInput,
55        ) -> impl std::future::Future<Output = Result<serde_json::Value>> {
56            async { Ok(json!({})) }
57        }
58        let _ = method_signature; // Use the function to avoid unused warnings
59    }
60}