MCPcopy Create free account
hub / github.com/AI45Lab/Code / resolve_auth_header

Method resolve_auth_header

core/src/mcp/manager.rs:315–336  ·  view source on GitHub ↗

Resolve an OAuth config into a `(header-name, header-value)` pair. - If `oauth.access_token` is set, uses it directly (static token). - Otherwise, performs a client credentials exchange. - If `oauth` is `None`, returns `Ok(None)` (no auth needed).

(oauth: Option<&OAuthConfig>)

Source from the content-addressed store, hash-verified

313 /// - Otherwise, performs a client credentials exchange.
314 /// - If `oauth` is `None`, returns `Ok(None)` (no auth needed).
315 async fn resolve_auth_header(oauth: Option<&OAuthConfig>) -> Result<Option<(String, String)>> {
316 let Some(oauth) = oauth else {
317 return Ok(None);
318 };
319
320 let token = if let Some(static_token) = &oauth.access_token {
321 static_token.clone()
322 } else {
323 oauth::exchange_client_credentials(
324 &oauth.token_url,
325 &oauth.client_id,
326 oauth.client_secret.as_deref().unwrap_or(""),
327 &oauth.scopes,
328 )
329 .await?
330 };
331
332 Ok(Some((
333 "Authorization".to_string(),
334 format!("Bearer {}", token),
335 )))
336 }
337
338 /// Parse MCP tool full name into (server, tool)
339 fn parse_tool_name(full_name: &str) -> Result<(String, String)> {

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.45

Tested by

no test coverage detected