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

Method connect_http_inner

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

Source from the content-addressed store, hash-verified

268 }
269
270 async fn connect_http_inner(
271 &self,
272 url: String,
273 headers: Option<HashMap<String, String>>,
274 ) -> Result<(), McpClientError> {
275 // If we have an OAuth manager, try to inject the bearer token.
276 let mut merged_headers = headers.unwrap_or_default();
277 if let Some(mgr) = self.oauth_manager.read().await.as_ref() {
278 match mgr.get_token().await {
279 Ok(Some(token)) => {
280 merged_headers.insert("Authorization".to_string(), format!("Bearer {token}"));
281 }
282 Ok(None) => {
283 // No token available – caller should initiate auth.
284 return Err(McpClientError::Unauthorized);
285 }
286 Err(e) => {
287 return Err(McpClientError::OAuthError(e.to_string()));
288 }
289 }
290 }
291
292 let transport = HttpTransport::new(url, Some(merged_headers));
293 {
294 let mut t = self.transport.lock().await;
295 *t = Some(Box::new(transport));
296 }
297 self.initialize().await?;
298 self.load_tools().await?;
299 Ok(())
300 }
301 pub async fn connect_sse(
302 &self,
303 url: String,

Callers 1

connect_httpMethod · 0.80

Calls 6

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

Tested by

no test coverage detected