| 202 | } |
| 203 | |
| 204 | async fn notify(&self, notification: JsonRpcNotification) -> Result<()> { |
| 205 | if !self.connected.load(Ordering::SeqCst) { |
| 206 | return Err(anyhow!("Transport not connected")); |
| 207 | } |
| 208 | |
| 209 | let msg = serde_json::to_string(¬ification)? + "\n"; |
| 210 | self.stdin_tx |
| 211 | .send(msg) |
| 212 | .await |
| 213 | .map_err(|_| anyhow!("Failed to send notification"))?; |
| 214 | |
| 215 | Ok(()) |
| 216 | } |
| 217 | |
| 218 | fn notifications(&self) -> mpsc::Receiver<McpNotification> { |
| 219 | // This is a bit awkward - we need to take ownership of the receiver |