MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / add_stdio

Method add_stdio

crates/opencode-mcp/src/client.rs:711–747  ·  view source on GitHub ↗
(
        &self,
        config: McpServerConfig,
    )

Source from the content-addressed store, hash-verified

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,

Callers 2

add_clientMethod · 0.80
restartMethod · 0.80

Calls 9

newFunction · 0.85
with_timeoutMethod · 0.80
connect_stdioMethod · 0.80
server_nameMethod · 0.80
cloneMethod · 0.45
log_eventMethod · 0.45
with_busMethod · 0.45
set_statusMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected