Skip to main content

do_memory_mcp/server/tools/embeddings/
test.rs

1//! Test embeddings tool handler for MCP server
2//!
3//! This module provides the tool for testing embedding provider
4//! connectivity and functionality.
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 test_embeddings tool
14    ///
15    /// # Returns
16    ///
17    /// Returns embedding provider test results
18    pub async fn execute_test_embeddings(&self) -> Result<serde_json::Value> {
19        self.track_tool_usage("test_embeddings").await;
20
21        debug!("Testing embedding provider connectivity");
22
23        let tool = crate::mcp::tools::embeddings::EmbeddingTools::new(Arc::clone(&self.memory));
24
25        let result = tool.execute_test_embeddings().await?;
26
27        // Convert result to JSON
28        Ok(json!(result))
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35
36    #[test]
37    #[allow(clippy::manual_async_fn)]
38    fn test_test_embeddings_signature_compile() {
39        // This test ensures the method signature compiles correctly
40        fn method_signature(
41            _server: &MemoryMCPServer,
42        ) -> impl std::future::Future<Output = Result<serde_json::Value>> {
43            async { Ok(json!({})) }
44        }
45        let _ = method_signature; // Use the function to avoid unused warnings
46    }
47}