MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / refresh_tools_if_needed

Method refresh_tools_if_needed

crates/opencode-mcp/src/client.rs:530–542  ·  view source on GitHub ↗

If the server sent a `tools/list_changed` notification, reload tools. Call this after operations that might trigger notifications.

(&self)

Source from the content-addressed store, hash-verified

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?;

Calls 2

load_toolsMethod · 0.80
publishMethod · 0.80

Tested by

no test coverage detected