MCPcopy Create free account
hub / github.com/modelcontextprotocol/typescript-sdk / buildWellKnownPath

Function buildWellKnownPath

src/client/auth.ts:795–806  ·  view source on GitHub ↗

* Constructs the well-known path for auth-related metadata discovery

(
    wellKnownPrefix: 'oauth-authorization-server' | 'oauth-protected-resource' | 'openid-configuration',
    pathname: string = '',
    options: { prependPathname?: boolean } = {}
)

Source from the content-addressed store, hash-verified

793 * Constructs the well-known path for auth-related metadata discovery
794 */
795function buildWellKnownPath(
796 wellKnownPrefix: 'oauth-authorization-server' | 'oauth-protected-resource' | 'openid-configuration',
797 pathname: string = '',
798 options: { prependPathname?: boolean } = {}
799): string {
800 // Strip trailing slash from pathname to avoid double slashes
801 if (pathname.endsWith('/')) {
802 pathname = pathname.slice(0, -1);
803 }
804
805 return options.prependPathname ? `${pathname}/.well-known/${wellKnownPrefix}` : `/.well-known/${wellKnownPrefix}${pathname}`;
806}
807
808/**
809 * Tries to discover OAuth metadata at a specific URL

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…