If the server sent a `tools/list_changed` notification, reload tools. Call this after operations that might trigger notifications.
(&self)
| 528 | /// If the server sent a `tools/list_changed` notification, reload tools. |
| 529 | /// Call this after operations that might trigger notifications. |
| 530 | pub async fn refresh_tools_if_needed(&self) -> Result<(), McpClientError> { |
| 531 | if self.tools_changed.swap(false, Ordering::SeqCst) { |
| 532 | self.load_tools().await?; |
| 533 | if let Some(bus) = &self.bus { |
| 534 | bus.publish( |
| 535 | &MCP_TOOLS_CHANGED_EVENT, |
| 536 | serde_json::json!({ "server": self.server_name }), |
| 537 | ) |
| 538 | .await; |
| 539 | } |
| 540 | } |
| 541 | Ok(()) |
| 542 | } |
| 543 | |
| 544 | async fn load_tools(&self) -> Result<(), McpClientError> { |
| 545 | let response = self.send_request("tools/list", None).await?; |
no test coverage detected