do_memory_mcp/server/tools/external_signals/
test_connection.rs1use crate::server::MemoryMCPServer;
9use anyhow::Result;
10use serde_json::json;
11use tracing::debug;
12
13impl MemoryMCPServer {
14 pub async fn execute_test_agentfs_connection(
24 &self,
25 input: crate::mcp::tools::external_signals::TestAgentFsConnectionInput,
26 ) -> Result<serde_json::Value> {
27 self.track_tool_usage("test_agentfs_connection").await;
28
29 debug!(
30 "Testing AgentFS connection for db_path: {:?}",
31 input.db_path
32 );
33
34 let start_time = std::time::Instant::now();
35 let test_duration_ms = start_time.elapsed().as_millis() as u64;
36
37 let result = crate::mcp::tools::external_signals::TestAgentFsConnectionOutput {
41 success: false, provider: "agentfs".to_string(),
43 db_path: input
44 .db_path
45 .unwrap_or_else(|| "/path/to/agentfs.db".to_string()),
46 connection_time_ms: test_duration_ms,
47 readable: false, writable: false,
49 toolcall_count: None, version: None, message: "AgentFS SDK not integrated - stub implementation cannot connect to real database".to_string(),
52 error: Some("SDK unavailable: agentfs-sdk dependency not added to project. Add dependency and enable 'agentfs' feature for real connection testing.".to_string()),
53 };
54
55 Ok(json!(result))
56 }
57}
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 #[allow(clippy::manual_async_fn)]
65 fn test_test_agentfs_connection_signature_compile() {
66 use crate::mcp::tools::external_signals::TestAgentFsConnectionInput;
68 fn method_signature(
69 _server: &MemoryMCPServer,
70 _input: TestAgentFsConnectionInput,
71 ) -> impl std::future::Future<Output = Result<serde_json::Value>> {
72 async { Ok(json!({})) }
73 }
74 let _ = method_signature; }
76
77 #[test]
78 fn test_stub_result_indicates_sdk_unavailable() {
79 let result = crate::mcp::tools::external_signals::TestAgentFsConnectionOutput {
81 success: false,
82 provider: "agentfs".to_string(),
83 db_path: "/tmp/test.db".to_string(),
84 connection_time_ms: 0,
85 readable: false,
86 writable: false,
87 toolcall_count: None,
88 version: None,
89 message: "SDK not integrated".to_string(),
90 error: Some("SDK unavailable".to_string()),
91 };
92
93 assert!(!result.success, "Stub should report unsuccessful test");
94 assert!(result.error.is_some(), "Should have error message");
95 assert!(!result.readable, "Should report not readable");
96 assert!(
97 result.toolcall_count.is_none(),
98 "Should have no toolcall count"
99 );
100 }
101}