MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / GetAuthServerMetadata

Function GetAuthServerMetadata

auth/shared.go:23–34  ·  view source on GitHub ↗

GetAuthServerMetadata fetches authorization server metadata for the given issuer URL. It tries standard well-known endpoints (OAuth 2.0 and OIDC) and returns the first successful result. Returns (nil, nil) when no metadata endpoints respond (404s), allowing callers to implement fallback logic. Retu

(ctx context.Context, issuerURL string, httpClient *http.Client)

Source from the content-addressed store, hash-verified

21// Returns (nil, nil) when no metadata endpoints respond (404s), allowing callers to implement
22// fallback logic. Returns an error for any non-client error (network failures, invalid JSON, etc.).
23func GetAuthServerMetadata(ctx context.Context, issuerURL string, httpClient *http.Client) (*oauthex.AuthServerMeta, error) {
24 for _, metadataURL := range authorizationServerMetadataURLs(issuerURL) {
25 asm, err := oauthex.GetAuthServerMeta(ctx, metadataURL, issuerURL, httpClient)
26 if err != nil {
27 return nil, err
28 }
29 if asm != nil {
30 return asm, nil
31 }
32 }
33 return nil, nil
34}
35
36// authorizationServerMetadataURLs returns a list of URLs to try when looking for
37// authorization server metadata as mandated by the MCP specification:

Callers 7

initiateOIDCLoginFunction · 0.92
AuthorizeMethod · 0.92
AuthorizeMethod · 0.92
TestHandleRegistrationFunction · 0.85
TestDynamicRegistrationFunction · 0.85
AuthorizeMethod · 0.85

Calls 2

GetAuthServerMetaFunction · 0.92

Tested by 3

TestHandleRegistrationFunction · 0.68
TestDynamicRegistrationFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…