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

Method connect_sse_inner

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

Source from the content-addressed store, hash-verified

323 }
324
325 async fn connect_sse_inner(
326 &self,
327 url: String,
328 headers: Option<HashMap<String, String>>,
329 ) -> Result<(), McpClientError> {
330 let mut merged_headers = headers.unwrap_or_default();
331 if let Some(mgr) = self.oauth_manager.read().await.as_ref() {
332 match mgr.get_token().await {
333 Ok(Some(token)) => {
334 merged_headers.insert("Authorization".to_string(), format!("Bearer {token}"));
335 }
336 Ok(None) => return Err(McpClientError::Unauthorized),
337 Err(e) => return Err(McpClientError::OAuthError(e.to_string())),
338 }
339 }
340
341 let transport = SseTransport::new(url, Some(merged_headers));
342 transport.connect().await?;
343 {
344 let mut t = self.transport.lock().await;
345 *t = Some(Box::new(transport));
346 }
347 self.initialize().await?;
348 self.load_tools().await?;
349 Ok(())
350 }
351
352 // -- Internal helpers ----------------------------------------------------
353

Callers 1

connect_sseMethod · 0.80

Calls 7

OAuthErrorEnum · 0.85
newFunction · 0.85
readMethod · 0.80
get_tokenMethod · 0.80
load_toolsMethod · 0.80
connectMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected