diff --git a/stub/src/main.rs b/stub/src/main.rs index 49156bf..abd91f8 100644 --- a/stub/src/main.rs +++ b/stub/src/main.rs @@ -56,6 +56,7 @@ fn main() -> Result<(), Box> { 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> { 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 {