import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js'; import type { OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js'; import type { ToolDef } from './tools.js'; import type { JsonObject } from './types.js'; export interface McpToolDescriptor { name: string; description?: string; inputSchema?: JsonObject; } export interface McpClientLike { listTools(): Promise; callTool(input: { name: string; arguments?: unknown; }, options?: { signal?: AbortSignal; }): Promise; } export interface CreateMcpToolsOptions { prefix?: string; effect?: 'read' | 'write' | 'execute' | 'none'; source?: string; /** Only expose remote tool names matching these exact names or `*` globs. */ allowTools?: string[]; /** Hide matching remote tool names even when allowed. */ denyTools?: string[]; } export type McpTransport = 'streamable-http' | 'sse'; type HeaderInput = Record | Array<[string, string]> | Headers; export interface McpServerOptions { url: string | URL; /** Defaults to modern streamable HTTP. Use 'sse' for legacy MCP servers. */ transport?: McpTransport; headers?: HeaderInput; requestInit?: RequestInit; fetch?: typeof fetch; clientName?: string; clientVersion?: string; /** OAuth provider used by the MCP SDK for authorization and automatic token refresh. */ authProvider?: OAuthClientProvider; /** Authorization code received at the configured callback URL. */ authorizationCode?: string; /** Only expose remote tool names matching these exact names or `*` globs. */ allowTools?: string[]; /** Hide matching remote tool names even when allowed. */ denyTools?: string[]; /** Streamable HTTP reconnect policy for resumable server event streams. */ reconnection?: { initialReconnectionDelay?: number; maxReconnectionDelay?: number; reconnectionDelayGrowFactor?: number; maxRetries?: number; }; } export interface McpServerConnection { name: string; tools: ToolDef[]; /** Close the current transport and discover tools again using the same auth configuration. */ reconnect(): Promise; close(): Promise; } export interface McpClientCredentialsOptions { clientId: string; clientSecret: string; clientName?: string; scope?: string; } /** OAuth client-credentials provider with MCP SDK token refresh handling. */ export declare function createMcpClientCredentialsAuth(options: McpClientCredentialsOptions): OAuthClientProvider; export interface McpAuthorizationCodeState { clientInformation?: OAuthClientInformationMixed; tokens?: OAuthTokens; codeVerifier?: string; } export interface McpAuthorizationCodeOptions { redirectUrl: string | URL; clientName: string; clientId?: string; clientSecret?: string; scopes?: string[]; /** Called with the provider authorization URL; open it in the user's browser. */ onAuthorizationUrl(url: URL): void | Promise; /** Load OAuth material from application-owned encrypted storage. Defaults to process memory. */ loadState?: () => McpAuthorizationCodeState | undefined | Promise; /** Persist OAuth material in application-owned encrypted storage. Defaults to process memory. */ saveState?: (state: McpAuthorizationCodeState) => void | Promise; } /** Authorization-code + PKCE provider; the MCP SDK refreshes stored tokens automatically. */ export declare function createMcpAuthorizationCodeAuth(options: McpAuthorizationCodeOptions): OAuthClientProvider; export declare function createMcpTools(client: McpClientLike, options?: CreateMcpToolsOptions): Promise; export declare function connectMcpServer(name: string, options: McpServerOptions): Promise; export {}; //# sourceMappingURL=mcp.d.ts.map