-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmcp_runtime.cpp
More file actions
37 lines (30 loc) · 1.16 KB
/
Copy pathmcp_runtime.cpp
File metadata and controls
37 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "mcp_runtime.hpp"
#include "../utils/logger.hpp"
namespace acecode::daemon {
DaemonMcpRuntime::~DaemonMcpRuntime() {
shutdown();
}
bool DaemonMcpRuntime::start(const AppConfig& cfg, ToolExecutor& tools) {
if (!manager_.connect_all(cfg)) {
return false;
}
LOG_INFO("[daemon:mcp] starting " +
std::to_string(manager_.configured_server_count()) +
" server(s) in the background");
manager_.set_status_callback([](const acecode::McpServerInfo& info) {
if (info.state == acecode::McpServerState::Connected) {
LOG_INFO("[daemon:mcp] server '" + info.name + "' connected with " +
std::to_string(info.tool_count) + " tool(s)");
} else if (info.state == acecode::McpServerState::Failed ||
info.state == acecode::McpServerState::TimedOut) {
LOG_WARN("[daemon:mcp] server '" + info.name + "' failed" +
(info.error.empty() ? std::string{} : (": " + info.error)));
}
});
manager_.start_async(tools);
return true;
}
void DaemonMcpRuntime::shutdown() {
manager_.shutdown();
}
} // namespace acecode::daemon