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

Method add_http

crates/opencode-mcp/src/client.rs:748–789  ·  view source on GitHub ↗
(
        &self,
        name: String,
        url: String,
        headers: Option<HashMap<String, String>>,
        timeout_ms: Option<u64>,
    )

Source from the content-addressed store, hash-verified

746 }
747 }
748 pub async fn add_http(
749 &self,
750 name: String,
751 url: String,
752 headers: Option<HashMap<String, String>>,
753 timeout_ms: Option<u64>,
754 ) -> Result<Arc<McpClient>, McpClientError> {
755 self.connection_configs.write().await.insert(
756 name.clone(),
757 RegistryConnectionConfig::Http {
758 url: url.clone(),
759 headers: headers.clone(),
760 timeout_ms,
761 },
762 );
763 self.log_event(&name, "Connecting via http").await;
764
765 let mut client_impl = McpClient::new(name.clone(), self.tool_registry.clone());
766 if let Some(t) = timeout_ms {
767 client_impl = client_impl.with_timeout(t);
768 }
769 if let Some(bus) = &self.bus {
770 client_impl = client_impl.with_bus(bus.clone());
771 }
772 let client = Arc::new(client_impl);
773
774 match client.connect_http(url, headers).await {
775 Ok(()) => {
776 self.set_status(&name, McpStatus::Connected).await;
777 self.clients.write().await.insert(name, client.clone());
778 self.log_event(client.server_name(), "Connected").await;
779 Ok(client)
780 }
781 Err(e) => {
782 let status = client.status().await;
783 self.set_status(&name, status).await;
784 self.log_event(&name, format!("Connect failed: {}", e))
785 .await;
786 Err(e)
787 }
788 }
789 }
790
791 pub async fn add_sse(
792 &self,

Callers 1

restartMethod · 0.80

Calls 9

newFunction · 0.85
with_timeoutMethod · 0.80
connect_httpMethod · 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