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

Method add_sse

crates/opencode-mcp/src/client.rs:791–832  ·  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

789 }
790
791 pub async fn add_sse(
792 &self,
793 name: String,
794 url: String,
795 headers: Option<HashMap<String, String>>,
796 timeout_ms: Option<u64>,
797 ) -> Result<Arc<McpClient>, McpClientError> {
798 self.connection_configs.write().await.insert(
799 name.clone(),
800 RegistryConnectionConfig::Sse {
801 url: url.clone(),
802 headers: headers.clone(),
803 timeout_ms,
804 },
805 );
806 self.log_event(&name, "Connecting via sse").await;
807
808 let mut client_impl = McpClient::new(name.clone(), self.tool_registry.clone());
809 if let Some(t) = timeout_ms {
810 client_impl = client_impl.with_timeout(t);
811 }
812 if let Some(bus) = &self.bus {
813 client_impl = client_impl.with_bus(bus.clone());
814 }
815 let client = Arc::new(client_impl);
816
817 match client.connect_sse(url, headers).await {
818 Ok(()) => {
819 self.set_status(&name, McpStatus::Connected).await;
820 self.clients.write().await.insert(name, client.clone());
821 self.log_event(client.server_name(), "Connected").await;
822 Ok(client)
823 }
824 Err(e) => {
825 let status = client.status().await;
826 self.set_status(&name, status).await;
827 self.log_event(&name, format!("Connect failed: {}", e))
828 .await;
829 Err(e)
830 }
831 }
832 }
833
834 /// Backwards-compatible alias for `add_stdio`.
835 pub async fn add_client(

Callers 1

restartMethod · 0.80

Calls 9

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