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

Function authorizationServerMetadataURLs

auth/shared.go:39–69  ·  view source on GitHub ↗

authorizationServerMetadataURLs returns a list of URLs to try when looking for authorization server metadata as mandated by the MCP specification: https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization#authorization-server-metadata-discovery.

(issuerURL string)

Source from the content-addressed store, hash-verified

37// authorization server metadata as mandated by the MCP specification:
38// https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization#authorization-server-metadata-discovery.
39func authorizationServerMetadataURLs(issuerURL string) []string {
40 var urls []string
41
42 baseURL, err := url.Parse(issuerURL)
43 if err != nil {
44 return nil
45 }
46
47 if baseURL.Path == "" {
48 // "OAuth 2.0 Authorization Server Metadata".
49 baseURL.Path = "/.well-known/oauth-authorization-server"
50 urls = append(urls, baseURL.String())
51 // "OpenID Connect Discovery 1.0".
52 baseURL.Path = "/.well-known/openid-configuration"
53 urls = append(urls, baseURL.String())
54 return urls
55 }
56
57 originalPath := baseURL.Path
58 // "OAuth 2.0 Authorization Server Metadata with path insertion".
59 baseURL.Path = "/.well-known/oauth-authorization-server/" + strings.TrimLeft(originalPath, "/")
60 urls = append(urls, baseURL.String())
61 // "OpenID Connect Discovery 1.0 with path insertion".
62 baseURL.Path = "/.well-known/openid-configuration/" + strings.TrimLeft(originalPath, "/")
63 urls = append(urls, baseURL.String())
64 // "OpenID Connect Discovery 1.0 with path appending".
65 baseURL.Path = "/" + strings.Trim(originalPath, "/") + "/.well-known/openid-configuration"
66 urls = append(urls, baseURL.String())
67
68 return urls
69}

Callers 1

GetAuthServerMetadataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…