MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getScopeFromMetadata

Function getScopeFromMetadata

src/services/mcp/auth.ts:2445–2465  ·  view source on GitHub ↗

* Safely extracts scope information from AuthorizationServerMetadata. * The metadata can be either OAuthMetadata or OpenIdProviderDiscoveryMetadata, * and different providers use different fields for scope information.

(
  metadata: AuthorizationServerMetadata | undefined,
)

Source from the content-addressed store, hash-verified

2443 * and different providers use different fields for scope information.
2444 */
2445function getScopeFromMetadata(
2446 metadata: AuthorizationServerMetadata | undefined,
2447): string | undefined {
2448 if (!metadata) return undefined
2449 // Try 'scope' first (non-standard but used by some providers)
2450 if ('scope' in metadata && typeof metadata.scope === 'string') {
2451 return metadata.scope
2452 }
2453 // Try 'default_scope' (non-standard but used by some providers)
2454 if (
2455 'default_scope' in metadata &&
2456 typeof metadata.default_scope === 'string'
2457 ) {
2458 return metadata.default_scope
2459 }
2460 // Fall back to scopes_supported (standard OAuth 2.0 field)
2461 if (metadata.scopes_supported && Array.isArray(metadata.scopes_supported)) {
2462 return metadata.scopes_supported.join(' ')
2463 }
2464 return undefined
2465}
2466

Callers 3

performMCPOAuthFlowFunction · 0.85
clientMetadataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected