UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

69 lines 3 kB
import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js"; import type { OAuthClientInformation, OAuthClientMetadata, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js"; /** * Browser-compatible OAuth client provider for MCP using localStorage. */ export declare class BrowserOAuthClientProvider implements OAuthClientProvider { readonly serverUrl: string; readonly storageKeyPrefix: string; readonly serverUrlHash: string; readonly clientName: string; readonly clientUri: string; readonly logoUri: string; readonly callbackUrl: string; private preventAutoAuth?; private useRedirectFlow?; private oauthProxyUrl?; private connectionUrl?; private originalFetch?; readonly onPopupWindow: ((url: string, features: string, window: globalThis.Window | null) => void) | undefined; constructor(serverUrl: string, options?: { storageKeyPrefix?: string; clientName?: string; clientUri?: string; logoUri?: string; callbackUrl?: string; preventAutoAuth?: boolean; useRedirectFlow?: boolean; oauthProxyUrl?: string; connectionUrl?: string; onPopupWindow?: (url: string, features: string, window: globalThis.Window | null) => void; }); /** * Install fetch interceptor to proxy OAuth requests through the backend */ installFetchInterceptor(): void; /** * Restore original fetch after OAuth flow completes */ restoreFetch(): void; get redirectUrl(): string; get clientMetadata(): OAuthClientMetadata; clientInformation(): Promise<OAuthClientInformation | undefined>; saveClientInformation(clientInformation: OAuthClientInformation): Promise<void>; tokens(): Promise<OAuthTokens | undefined>; saveTokens(tokens: OAuthTokens): Promise<void>; saveCodeVerifier(codeVerifier: string): Promise<void>; codeVerifier(): Promise<string>; /** * Generates and stores the authorization URL with state, without opening a popup. * Used when preventAutoAuth is enabled to provide the URL for manual navigation. * @param authorizationUrl The fully constructed authorization URL from the SDK. * @returns The full authorization URL with state parameter. */ prepareAuthorizationUrl(authorizationUrl: URL): Promise<string>; /** * Redirects the user agent to the authorization URL, storing necessary state. * This now adheres to the SDK's void return type expectation for the interface. * @param authorizationUrl The fully constructed authorization URL from the SDK. */ redirectToAuthorization(authorizationUrl: URL): Promise<void>; /** * Retrieves the last URL passed to `redirectToAuthorization`. Useful for manual fallback. */ getLastAttemptedAuthUrl(): string | null; clearStorage(): number; private hashString; getKey(keySuffix: string): string; } //# sourceMappingURL=browser-provider.d.ts.map