44 lines
1.9 KiB
C++
44 lines
1.9 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include "mcp/KomMcpServer.hpp"
|
|
#include "mcp/RegisterTools.hpp"
|
|
|
|
namespace {
|
|
|
|
bool expect_contains(const std::string& haystack, const std::string& needle, const std::string& context) {
|
|
if (haystack.find(needle) == std::string::npos) {
|
|
std::cerr << "Expected response to contain '" << needle << "' but got:\n"
|
|
<< haystack << "\nContext: " << context << "\n";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
KomMcpServer server;
|
|
register_default_tools(server);
|
|
|
|
const std::string upsertReq = R"({"namespace":"tests","items":[{"text":"hello world"},{"text":"hola mundo"}]})";
|
|
std::string upsertResp = server.dispatch("kom.memory.v1.upsert_memory", upsertReq);
|
|
if (!expect_contains(upsertResp, "\"upserted\":2", "upsert_memory count")) return 1;
|
|
if (!expect_contains(upsertResp, "\"status\":\"ok\"", "upsert_memory status")) return 1;
|
|
|
|
const std::string searchReq = R"({"namespace":"tests","query":{"text":"hello","k":3}})";
|
|
std::string searchResp = server.dispatch("kom.memory.v1.search_memory", searchReq);
|
|
if (!expect_contains(searchResp, "\"matches\"", "search_memory matches key")) return 1;
|
|
if (!expect_contains(searchResp, "\"text\":\"hello\"", "search_memory echo text")) return 1;
|
|
|
|
const std::string exportReq = R"({"namespace":"tests","destination":"/tmp/example.enc"})";
|
|
std::string exportResp = server.dispatch("kom.local.v1.backup.export_encrypted", exportReq);
|
|
if (!expect_contains(exportResp, "\"status\":\"queued\"", "export status")) return 1;
|
|
if (!expect_contains(exportResp, "\"artifact\"", "export artifact path")) return 1;
|
|
|
|
const std::string importReq = R"({"namespace":"tests","source":"/tmp/example.enc"})";
|
|
std::string importResp = server.dispatch("kom.local.v1.backup.import_encrypted", importReq);
|
|
if (!expect_contains(importResp, "\"status\":\"ok\"", "import status")) return 1;
|
|
|
|
return 0;
|
|
}
|