24#include <condition_variable>
70 uint32_t health_check_interval_ms = 0);
87 void unwatch(
const std::string& name);
116 uint32_t health_check_interval_ms_;
126 uint32_t reconnect_attempt;
127 std::chrono::steady_clock::time_point next_action;
130 std::map<std::string, WatchEntry> watched_;
131 std::mutex watched_mutex_;
133 std::vector<HealthEvent> event_queue_;
134 std::mutex event_mutex_;
136 std::thread monitor_thread_;
137 std::atomic<bool> running_{
false};
138 std::condition_variable wake_cv_;
139 std::mutex wake_mutex_;
155 void check_server(
const std::string& name, WatchEntry& entry);
164 void attempt_reconnect(
const std::string& name,
178 void on_reconnect_success(
const std::string& name,
189 void post_event(
const std::string& name,
190 const std::string& old_status,
191 const std::string& new_status);
Client for an external MCP server (stdio or SSE).
Monitors external server connections and handles reconnection.
void start()
Start the monitoring thread.
void watch(const std::string &name, ExternalMCPClient *client)
Start monitoring a server.
void stop()
Stop monitoring and all reconnection attempts.
std::function< void(const HealthEvent &)> StatusCallback
Callback invoked on engine thread when processing events.
void process_events()
Drain event queue, invoke callbacks (call on engine thread).
~HealthMonitor()
Destructor — stops monitor if running.
void set_status_callback(StatusCallback cb)
Set callback for status change events.
void unwatch(const std::string &name)
Stop monitoring a server.
Exponential backoff with jitter for reconnection attempts.
Client for communicating with external MCP servers.
Activate model on GPU (WARM → ACTIVE).
Exponential backoff reconnection policy.
Status change event posted by the monitor thread.
std::vector< std::string > added_tools
Tools added on refresh.
std::string server_name
Which server changed.
std::string old_status
Previous status.
std::string new_status
New status.
std::vector< std::string > removed_tools
Tools removed on refresh.