feat(stub): implement ADR-0047 tools/list_changed on reconnect

This commit is contained in:
Riz Ashraf committed 2026-10-11 18:45:12 +01:00
1 parent 9e02639d0d
commit 33b1a4e3e6
1 file changed
+16
+16
View File
@@ -56,6 +56,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let ws_url = format!("{ws_url}/ws?client=proxy");
let mut retry_count = 0;
let mut has_connected_once = false;
loop {
if *shutdown_rx.borrow() {
tracing::info!("Stub shutdown requested");
@@ -91,6 +92,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing::info!("Successfully connected to target server");
let (mut write, mut read) = ws_stream.split();
if has_connected_once {
tracing::info!("Synthesizing notifications/tools/list_changed to client due to reconnect");
use tokio::io::AsyncWriteExt;
let mut stdout = tokio::io::BufWriter::new(tokio::io::stdout());
let notification = serde_json::json!({
"jsonrpc": "2.0",
"method": "notifications/tools/list_changed"
});
let payload = notification.to_string();
let _ = stdout.write_all(payload.as_bytes()).await;
let _ = stdout.write_all(b"\n").await;
let _ = stdout.flush().await;
}
has_connected_once = true;
let rx = msg_rx.clone();
let mut send_task = tokio::spawn(async move {
while let Ok(msg) = rx.recv().await {