(
&self,
config: McpServerConfig,
)
| 709 | // -- Client management --------------------------------------------------- |
| 710 | |
| 711 | pub async fn add_stdio( |
| 712 | &self, |
| 713 | config: McpServerConfig, |
| 714 | ) -> Result<Arc<McpClient>, McpClientError> { |
| 715 | let name = config.name.clone(); |
| 716 | self.connection_configs.write().await.insert( |
| 717 | name.clone(), |
| 718 | RegistryConnectionConfig::Stdio(config.clone()), |
| 719 | ); |
| 720 | self.log_event(&name, "Connecting via stdio").await; |
| 721 | |
| 722 | let timeout = config.timeout_ms; |
| 723 | let mut client_impl = McpClient::new(name.clone(), self.tool_registry.clone()); |
| 724 | if let Some(timeout_ms) = timeout { |
| 725 | client_impl = client_impl.with_timeout(timeout_ms); |
| 726 | } |
| 727 | if let Some(bus) = &self.bus { |
| 728 | client_impl = client_impl.with_bus(bus.clone()); |
| 729 | } |
| 730 | let client = Arc::new(client_impl); |
| 731 | |
| 732 | match client.connect_stdio(config).await { |
| 733 | Ok(()) => { |
| 734 | self.set_status(&name, McpStatus::Connected).await; |
| 735 | self.clients.write().await.insert(name, client.clone()); |
| 736 | self.log_event(client.server_name(), "Connected").await; |
| 737 | Ok(client) |
| 738 | } |
| 739 | Err(e) => { |
| 740 | let status = client.status().await; |
| 741 | self.set_status(&name, status).await; |
| 742 | self.log_event(&name, format!("Connect failed: {}", e)) |
| 743 | .await; |
| 744 | Err(e) |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | pub async fn add_http( |
| 749 | &self, |
| 750 | name: String, |
no test coverage detected