mcp-use TypeScript API
    Preparing search index...

    Function completeOAuthFlow

    • Complete an in-progress or required OAuth authorization for provider.

      • Node loopback providers expose getAuthorizationCode(); we await the code and finish the token exchange.
      • Browser providers open a popup/redirect; we wait for the callback page (onMcpAuthorization) to exchange the code and signal success over BroadcastChannel / postMessage.

      Safe to call when the SDK transport already invoked auth() on a 401 (Node: hasPendingFlow; we skip a duplicate auth() in that case).

      Parameters

      • provider: OAuthClientProvider
      • serverUrl: string
      • options: {
            fetchFn?: {
                (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
                (input: string | URL | Request, init?: RequestInit): Promise<Response>;
            };
            timeoutMs?: number;
        } = {}
        • OptionalfetchFn?: {
              (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
              (input: string | URL | Request, init?: RequestInit): Promise<Response>;
          }
        • OptionaltimeoutMs?: number

      Returns Promise<void>