import { FetchFunction, FlexibleSchema, Tool } from "#compiled/@ai-sdk/provider-utils/index.js"; import { z } from "#compiled/zod/index.js"; import { AISDKError, JSONObject } from "#compiled/@ai-sdk/provider/index.js"; //#region src/tool/json-rpc-message.d.ts declare const JSONRPCRequestSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; id: z.ZodUnion; method: z.ZodString; params: z.ZodOptional>; }, z.core.$loose>>; }, z.core.$strict>; type JSONRPCRequest = z.infer; declare const JSONRPCResponseSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; id: z.ZodUnion; result: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; }, z.core.$loose>; }, z.core.$strict>; type JSONRPCResponse = z.infer; declare const JSONRPCErrorSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; id: z.ZodOptional>; error: z.ZodObject<{ code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strict>; type JSONRPCError = z.infer; declare const JSONRPCNotificationSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; method: z.ZodString; params: z.ZodOptional>; }, z.core.$loose>>; }, z.core.$strict>; type JSONRPCNotification = z.infer; declare const JSONRPCMessageSchema: z.ZodUnion; id: z.ZodUnion; method: z.ZodString; params: z.ZodOptional>; }, z.core.$loose>>; }, z.core.$strict>, z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; method: z.ZodString; params: z.ZodOptional>; }, z.core.$loose>>; }, z.core.$strict>, z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; id: z.ZodUnion; result: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; }, z.core.$loose>; }, z.core.$strict>, z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; id: z.ZodOptional>; error: z.ZodObject<{ code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strict>]>; type JSONRPCMessage = z.infer; export declare function validateJSONRPCMessage(message: unknown): JSONRPCMessage; //#endregion //#region src/tool/types.d.ts type McpProviderMetadata = { clientName?: string; title?: string; toolName?: string; annotations?: McpToolAnnotations; app?: JSONObject; }; /** * Behavioral hints reported by an MCP server for a tool. * * These annotations are untrusted unless the server itself is trusted. * * @see https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations */ type McpToolAnnotations = { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; }; /** MCP tool metadata - keys should follow MCP _meta key format specification */ declare const ToolMetaSchema: z.ZodOptional>; type ToolMeta = z.infer; type ToolSchemas = Record; outputSchema?: FlexibleSchema; }> | 'automatic' | undefined; /** Base MCP tool type with execute and _meta */ type McpToolBase = Tool & Required, 'execute'>> & { _meta?: ToolMeta; }; type McpToolSet = TOOL_SCHEMAS extends Record; outputSchema?: FlexibleSchema; }> ? { [K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends { inputSchema: FlexibleSchema; outputSchema: FlexibleSchema; } ? McpToolBase : TOOL_SCHEMAS[K] extends { inputSchema: FlexibleSchema; } ? McpToolBase : never; } : Record>; declare const ClientOrServerImplementationSchema: z.ZodObject<{ name: z.ZodString; version: z.ZodString; title: z.ZodOptional; }, z.core.$loose>; type Configuration = z.infer; declare const BaseParamsSchema: z.ZodObject<{ _meta: z.ZodOptional>; }, z.core.$loose>; type BaseParams = z.infer; declare const RequestSchema: z.ZodObject<{ method: z.ZodString; params: z.ZodOptional>; }, z.core.$loose>>; }, z.core.$strip>; type Request$1 = z.infer; type RequestOptions = { signal?: AbortSignal; timeout?: number; maxTotalTimeout?: number; }; declare const ClientCapabilitiesSchema: z.ZodObject<{ elicitation: z.ZodOptional; }, z.core.$loose>>; }, z.core.$loose>; type ClientCapabilities = z.infer; declare const InitializeResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; protocolVersion: z.ZodString; capabilities: z.ZodObject<{ events: z.ZodOptional>; }, z.core.$loose>>>; experimental: z.ZodOptional>; logging: z.ZodOptional>; completions: z.ZodOptional>; prompts: z.ZodOptional; }, z.core.$loose>>; resources: z.ZodOptional; listChanged: z.ZodOptional; }, z.core.$loose>>; tools: z.ZodOptional; }, z.core.$loose>>; elicitation: z.ZodOptional; }, z.core.$loose>>; }, z.core.$loose>; serverInfo: z.ZodObject<{ name: z.ZodString; version: z.ZodString; title: z.ZodOptional; }, z.core.$loose>; instructions: z.ZodOptional; }, z.core.$loose>; type InitializeResult = z.infer; type PaginatedRequest = Request$1 & { params?: BaseParams & { cursor?: string; }; }; declare const ListToolsResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; nextCursor: z.ZodOptional; tools: z.ZodArray; description: z.ZodOptional; inputSchema: z.ZodObject<{ type: z.ZodOptional; properties: z.ZodOptional>; }, z.core.$loose>; outputSchema: z.ZodOptional>; annotations: z.ZodOptional; readOnlyHint: z.ZodOptional; destructiveHint: z.ZodOptional; idempotentHint: z.ZodOptional; openWorldHint: z.ZodOptional; }, z.core.$loose>>; _meta: z.ZodOptional>; }, z.core.$loose>>; }, z.core.$loose>; type ListToolsResult = z.infer; declare const ListResourcesResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; nextCursor: z.ZodOptional; resources: z.ZodArray; description: z.ZodOptional; mimeType: z.ZodOptional; size: z.ZodOptional; }, z.core.$loose>>; }, z.core.$loose>; type ListResourcesResult = z.infer; declare const CallToolResultSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; content: z.ZodArray; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodBase64; mimeType: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"resource">; resource: z.ZodUnion; title: z.ZodOptional; mimeType: z.ZodOptional; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ uri: z.ZodString; name: z.ZodOptional; title: z.ZodOptional; mimeType: z.ZodOptional; blob: z.ZodBase64; }, z.core.$loose>]>; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"resource_link">; uri: z.ZodString; name: z.ZodString; description: z.ZodOptional; mimeType: z.ZodOptional; }, z.core.$loose>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>; structuredContent: z.ZodOptional; isError: z.ZodOptional>; }, z.core.$loose>, z.ZodPipe>; resultType: z.ZodOptional; content: z.ZodOptional; structuredContent: z.ZodJSONSchema; isError: z.ZodOptional>; }, z.core.$loose>, z.ZodTransform<{ [x: string]: unknown; content: ({ [x: string]: unknown; type: "text"; text: string; } | { [x: string]: unknown; type: "image"; data: string; mimeType: string; } | { [x: string]: unknown; type: "resource"; resource: { [x: string]: unknown; uri: string; text: string; name?: string | undefined; title?: string | undefined; mimeType?: string | undefined; } | { [x: string]: unknown; uri: string; blob: string; name?: string | undefined; title?: string | undefined; mimeType?: string | undefined; }; } | { [x: string]: unknown; type: "resource_link"; uri: string; name: string; description?: string | undefined; mimeType?: string | undefined; } | { [x: string]: unknown; type: string; })[]; _meta?: { [x: string]: unknown; } | undefined; resultType?: string | undefined; structuredContent?: unknown; isError?: boolean | undefined; }, { [x: string]: unknown; structuredContent: z.core.util.JSONType; _meta?: { [x: string]: unknown; } | undefined; resultType?: string | undefined; content?: undefined; isError?: boolean | undefined; }>>, z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; content: z.ZodArray; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodBase64; mimeType: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"resource">; resource: z.ZodUnion; title: z.ZodOptional; mimeType: z.ZodOptional; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ uri: z.ZodString; name: z.ZodOptional; title: z.ZodOptional; mimeType: z.ZodOptional; blob: z.ZodBase64; }, z.core.$loose>]>; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"resource_link">; uri: z.ZodString; name: z.ZodString; description: z.ZodOptional; mimeType: z.ZodOptional; }, z.core.$loose>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>; structuredContent: z.ZodOptional; isError: z.ZodOptional>; }, z.core.$loose>>]>, z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; toolResult: z.ZodNonOptional; }, z.core.$loose>]>; type CallToolResult = z.infer; declare const ListResourceTemplatesResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; resourceTemplates: z.ZodArray; description: z.ZodOptional; mimeType: z.ZodOptional; }, z.core.$loose>>; }, z.core.$loose>; type ListResourceTemplatesResult = z.infer; declare const ReadResourceResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; contents: z.ZodArray; title: z.ZodOptional; mimeType: z.ZodOptional; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ uri: z.ZodString; name: z.ZodOptional; title: z.ZodOptional; mimeType: z.ZodOptional; blob: z.ZodBase64; }, z.core.$loose>]>>; }, z.core.$loose>; type ReadResourceResult = z.infer; declare const CompleteRequestParamsSchema: z.ZodObject<{ _meta: z.ZodOptional>; ref: z.ZodUnion; name: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"ref/resource">; uri: z.ZodString; }, z.core.$loose>]>; argument: z.ZodObject<{ name: z.ZodString; value: z.ZodString; }, z.core.$loose>; context: z.ZodOptional; }, z.core.$loose>>; }, z.core.$loose>; type CompleteRequestParams = z.infer; declare const CompleteResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; completion: z.ZodObject<{ values: z.ZodArray; total: z.ZodOptional; hasMore: z.ZodOptional; }, z.core.$loose>; }, z.core.$loose>; type CompleteResult = z.infer; declare const ListPromptsResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; nextCursor: z.ZodOptional; prompts: z.ZodArray; description: z.ZodOptional; arguments: z.ZodOptional; required: z.ZodOptional; }, z.core.$loose>>>; }, z.core.$loose>>; }, z.core.$loose>; type ListPromptsResult = z.infer; declare const GetPromptResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; description: z.ZodOptional; messages: z.ZodArray, z.ZodLiteral<"assistant">]>; content: z.ZodUnion; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodBase64; mimeType: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"resource">; resource: z.ZodUnion; title: z.ZodOptional; mimeType: z.ZodOptional; text: z.ZodString; }, z.core.$loose>, z.ZodObject<{ uri: z.ZodString; name: z.ZodOptional; title: z.ZodOptional; mimeType: z.ZodOptional; blob: z.ZodBase64; }, z.core.$loose>]>; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"resource_link">; uri: z.ZodString; name: z.ZodString; description: z.ZodOptional; mimeType: z.ZodOptional; }, z.core.$loose>]>; }, z.core.$loose>>; }, z.core.$loose>; type GetPromptResult = z.infer; export declare const ElicitationRequestSchema: z.ZodObject<{ method: z.ZodLiteral<"elicitation/create">; params: z.ZodObject<{ _meta: z.ZodOptional>; message: z.ZodString; requestedSchema: z.ZodUnknown; }, z.core.$loose>; }, z.core.$strip>; type ElicitationRequest = z.infer; export declare const ElicitResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; action: z.ZodUnion, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>; content: z.ZodOptional>; }, z.core.$loose>; type ElicitResult = z.infer; //#endregion //#region src/tool/mcp-event-types.d.ts declare const MCPEventDefinitionSchema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional>; delivery: z.ZodArray>; inputSchema: z.ZodUnion]>; payloadSchema: z.ZodUnion]>; }, z.core.$loose>; type MCPEventDefinition = z.infer; declare const ListEventsResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; events: z.ZodArray>; delivery: z.ZodArray>; inputSchema: z.ZodUnion]>; payloadSchema: z.ZodUnion]>; }, z.core.$loose>>; nextCursor: z.ZodOptional>; }, z.core.$loose>; type ListEventsResult = z.infer; declare const SubscribeEventResultSchema: z.ZodObject<{ _meta: z.ZodOptional>; resultType: z.ZodOptional; id: z.ZodString; refreshBefore: z.ZodNullable; cursor: z.ZodPipe>, z.ZodTransform>; truncated: z.ZodBoolean; }, z.core.$loose>; type SubscribeEventResult = z.infer; declare const MCPEventSchema: z.ZodObject<{ eventId: z.ZodString; name: z.ZodString; timestamp: z.ZodISODateTime; data: z.ZodRecord; cursor: z.ZodOptional>; }, z.core.$loose>; type MCPEvent = z.infer; declare const MCPEventControlSchema: z.ZodPipe; cursor: z.ZodString; }, z.core.$loose>, z.ZodObject<{ type: z.ZodLiteral<"terminated">; error: z.ZodObject<{ code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional>; }, z.core.$loose>; }, z.core.$loose>]>, z.ZodTransform<{ [x: string]: unknown; type: "terminated"; error: { [x: string]: unknown; code: number; message: string; data?: unknown; }; } | { truncated: true; type: "gap"; cursor: string; }, { [x: string]: unknown; type: "gap"; cursor: string; } | { [x: string]: unknown; type: "terminated"; error: { [x: string]: unknown; code: number; message: string; data?: unknown; }; }>>; type MCPEventControl = z.infer; /** Persisted privately by the application, including the signing secret. */ type MCPEventSubscription = { key: string; id?: string; name: string; arguments: JSONObject; definition: MCPEventDefinition; delivery: { mode: 'webhook'; url: string; secret: string; }; refreshBefore?: string | null; cursor: string | null; truncated: boolean; ttlMs?: number | null; maxAgeMs?: number; status: 'pending' | 'active'; }; /** Subscription metadata safe to pass to event handlers; excludes the secret. */ type MCPEventSubscriptionInfo = { id: string; name: string; arguments: JSONObject; delivery: { mode: 'webhook'; url: string; }; refreshBefore: string | null; }; /** * Use durable, private storage scoped to one MCP server and authenticated * principal. update must atomically merge only the supplied fields. Never * expose these records to a browser: delivery.secret authenticates webhooks. */ interface MCPEventStore { get(key: string): Promise; getById(id: string): Promise; set(subscription: MCPEventSubscription): Promise; update(key: string, patch: Partial): Promise; delete(key: string): Promise; } type MCPEventsConfig = { store: MCPEventStore; adapter?: never; /** * Optionally validate subscription arguments using an application schema or * the server's inputSchema. Throw to reject before persisting or subscribing. */ validateArguments?: (args: { definition: MCPEventDefinition; arguments: JSONObject; }) => void | PromiseLike; } | { adapter: MCPEventAdapter; store?: never; validateArguments?: never; }; type SubscribeEventOptions = { name: string; arguments?: JSONObject; delivery: { mode: 'webhook'; /** HTTPS callback served by createMCPEventWebhook before subscribing. */ url: string; /** Development only: allow HTTP callbacks to literal loopback addresses. */ allowInsecureLocalhost?: boolean; /** Generated securely when omitted; persisted before the subscribe request. */ secret?: string; }; cursor?: string | null; ttlMs?: number | null; maxAgeMs?: number; options?: RequestOptions; }; type MCPEventSubscriptionOptions = ({ id: string; key?: never; } | { key: string; id?: never; }) & { options?: RequestOptions; }; interface MCPEvents { list(options?: { params?: { cursor?: string; }; options?: RequestOptions; }): Promise; subscribe(options: SubscribeEventOptions): Promise; refresh(options: MCPEventSubscriptionOptions): Promise; unsubscribe(options: MCPEventSubscriptionOptions): Promise; } //#endregion //#region src/tool/mcp-events-adapter.d.ts /** A durable watch owned by the adapter's backend, not an upstream MCP lease. */ type ManagedSubscription = { /** Backend subscription ID; use it for managed lifecycle operations. */ id: string; name: string; arguments: JSONObject; status: 'pending' | 'active' | 'needs_auth' | 'stopped' | 'expired' | 'failed'; /** Application monitoring deadline. null means until explicitly stopped. */ expiresAt: string | null; cleanupStatus?: 'pending' | 'complete' | 'exhausted'; }; type ManagedSubscribeInput = { name: string; arguments: JSONObject; /** Application metadata, not an authorization grant. */ context?: JSONObject; /** Reuse the original key when recovering an uncertain create result. */ idempotencyKey: string; options?: RequestOptions; } & ({ ttlMs: number; expiresAt?: never; } | { expiresAt: string | null; ttlMs?: never; }); /** * Bound to an authorized account and destination by the application. The backend * owns callback provisioning, verification, persistence, renewal and cleanup. * Implementations must honor request options and preserve actionable errors. * Cancelling a request does not cancel an already accepted remote subscription. */ interface MCPEventOperations { subscribe(input: ManagedSubscribeInput): Promise; getSubscription(input: { id: string; options?: RequestOptions; }): Promise; listSubscriptions(input?: { cursor?: string; limit?: number; status?: ManagedSubscription['status']; options?: RequestOptions; }): Promise<{ subscriptions: ManagedSubscription[]; nextCursor?: string; }>; unsubscribe(input: { id: string; options?: RequestOptions; }): Promise; } /** * Creates bound subscription operations once per client, before the transport starts. * Receives transport metadata, not credentials or a live transport instance. * HTTP/SSE URLs are the configured endpoints, not resolved redirect targets. * Custom transports have no standard URL and receive only their type. */ interface MCPEventAdapter { createAdapter(context: { transport: { type: 'http' | 'sse'; url: string; } | { type: 'custom'; }; }): MCPEventOperations; } /** Catalog discovery uses MCP; all subscription operations use the adapter. */ interface ManagedMCPEvents extends MCPEventOperations { list: MCPEvents['list']; } //#endregion //#region src/tool/oauth-types.d.ts /** * OAuth 2.1 token response */ declare const OAuthTokensSchema: z.ZodObject<{ access_token: z.ZodString; id_token: z.ZodOptional; token_type: z.ZodString; expires_in: z.ZodOptional; scope: z.ZodOptional; refresh_token: z.ZodOptional; issuer: z.ZodOptional; authorization_server: z.ZodOptional; token_endpoint: z.ZodOptional; }, z.core.$strip>; declare const OAuthMetadataSchema: z.ZodObject<{ issuer: z.ZodString; authorization_endpoint: z.ZodString; token_endpoint: z.ZodString; registration_endpoint: z.ZodOptional; authorization_response_iss_parameter_supported: z.ZodOptional; client_id_metadata_document_supported: z.ZodOptional; scopes_supported: z.ZodOptional>; response_types_supported: z.ZodArray; grant_types_supported: z.ZodOptional>; code_challenge_methods_supported: z.ZodOptional>; token_endpoint_auth_methods_supported: z.ZodOptional>; token_endpoint_auth_signing_alg_values_supported: z.ZodOptional>; }, z.core.$loose>; /** * OpenID Connect Discovery metadata that may include OAuth 2.0 fields * This schema represents the real-world scenario where OIDC providers * return a mix of OpenID Connect and OAuth 2.0 metadata fields */ declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{ issuer: z.ZodString; authorization_endpoint: z.ZodString; token_endpoint: z.ZodString; userinfo_endpoint: z.ZodOptional; jwks_uri: z.ZodString; registration_endpoint: z.ZodOptional; authorization_response_iss_parameter_supported: z.ZodOptional; client_id_metadata_document_supported: z.ZodOptional; scopes_supported: z.ZodOptional>; response_types_supported: z.ZodArray; grant_types_supported: z.ZodOptional>; subject_types_supported: z.ZodArray; id_token_signing_alg_values_supported: z.ZodArray; claims_supported: z.ZodOptional>; token_endpoint_auth_methods_supported: z.ZodOptional>; code_challenge_methods_supported: z.ZodOptional>; }, z.core.$loose>; declare const OAuthClientInformationSchema: z.ZodObject<{ client_id: z.ZodString; client_secret: z.ZodOptional; client_id_issued_at: z.ZodOptional; client_secret_expires_at: z.ZodOptional; issuer: z.ZodOptional; authorization_server: z.ZodOptional; token_endpoint: z.ZodOptional; }, z.core.$strip>; declare const OAuthClientMetadataSchema: z.ZodObject<{ redirect_uris: z.ZodArray; application_type: z.ZodOptional, z.ZodLiteral<"web">]>>; token_endpoint_auth_method: z.ZodOptional; grant_types: z.ZodOptional>; response_types: z.ZodOptional>; client_name: z.ZodOptional; client_uri: z.ZodOptional; logo_uri: z.ZodOptional; scope: z.ZodOptional; contacts: z.ZodOptional>; tos_uri: z.ZodOptional; policy_uri: z.ZodOptional; jwks_uri: z.ZodOptional; jwks: z.ZodOptional; software_id: z.ZodOptional; software_version: z.ZodOptional; software_statement: z.ZodOptional; }, z.core.$strip>; type OAuthMetadata = z.infer; type OpenIdProviderDiscoveryMetadata = z.infer; type OAuthTokens = z.infer; type OAuthClientInformation = z.infer; type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata; type OAuthClientMetadata = z.infer; //#endregion //#region src/error/oauth-error.d.ts declare const symbol$1: unique symbol; /** * An error occurred with the MCP client within the OAuth flow. */ export declare class MCPClientOAuthError extends AISDKError { private readonly [symbol$1]; constructor({ name, message, cause }: { name?: string; message: string; cause?: unknown; }); static isInstance(error: unknown): error is MCPClientOAuthError; } declare const mismatchSymbol: unique symbol; export declare class AuthorizationServerMismatchError extends MCPClientOAuthError { private readonly [mismatchSymbol]; static errorCode: string; constructor({ message, cause }: { message: string; cause?: unknown; }); static isInstance(error: unknown): error is AuthorizationServerMismatchError; } //#endregion //#region src/tool/oauth.d.ts type AuthResult = 'AUTHORIZED' | 'REDIRECT'; interface OAuthAuthorizationServerInformation { issuer?: string; authorizationServerUrl: string; tokenEndpoint: string; } interface OAuthClientProvider { /** * Returns current access token if present; undefined otherwise. */ tokens(): OAuthTokens | undefined | Promise; saveTokens(tokens: OAuthTokens): void | Promise; redirectToAuthorization(authorizationUrl: URL): void | Promise; saveCodeVerifier(codeVerifier: string): void | Promise; codeVerifier(): string | Promise; /** * Adds custom client authentication to OAuth token requests. * * This optional method allows implementations to customize how client credentials * are included in token exchange and refresh requests. When provided, this method * is called instead of the default authentication logic, giving full control over * the authentication mechanism. * * Common use cases include: * - Supporting authentication methods beyond the standard OAuth 2.0 methods * - Adding custom headers for proprietary authentication schemes * - Implementing client assertion-based authentication (e.g., JWT bearer tokens) * * @param headers - The request headers (can be modified to add authentication) * @param params - The request body parameters (can be modified to add credentials) * @param url - The token endpoint URL being called * @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods */ addClientAuthentication?(headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata): void | Promise; /** * If implemented, provides a way for the client to invalidate (e.g. delete) the specified * credentials, in the case where the server has indicated that they are no longer valid. * This avoids requiring the user to intervene manually. * * For token invalidation, context identifies the token generation being invalidated * when available. Providers sharing storage must atomically compare and delete * that generation so a concurrent refresh's tokens are preserved. Omitting or * ignoring context retains unconditional invalidation. */ invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier', context?: { tokens: OAuthTokens; }): void | Promise; get redirectUrl(): string | URL; get clientMetadata(): OAuthClientMetadata; clientInformation(): OAuthClientInformation | undefined | Promise; /** * Returns whether the current client information was obtained through * dynamic client registration. * * Return `true` only when the current client information was saved after a * dynamic registration response. When this method is omitted or returns * `false`, the client information is treated as pre-registered and is not * automatically invalidated after client authentication errors. */ isClientInformationDynamicallyRegistered?(): boolean | Promise; saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise; authorizationServerInformation?(): OAuthAuthorizationServerInformation | undefined | Promise; saveAuthorizationServerInformation?(authorizationServerInformation: OAuthAuthorizationServerInformation): void | Promise; /** * Validates an authorization server URL discovered from MCP protected resource * metadata before the client fetches its OAuth metadata. */ validateAuthorizationServerURL?(serverUrl: string | URL, authorizationServerUrl: string | URL): void | Promise; state?(): string | Promise; saveState?(state: string): void | Promise; storedState?(): string | undefined | Promise; validateResourceURL?(serverUrl: string | URL, resource?: string): Promise; } export declare class UnauthorizedError extends Error { constructor(message?: string); } export declare function auth(provider: OAuthClientProvider, options: { serverUrl: string | URL; authorizationCode?: string; callbackState?: string; /** * Value of the `iss` parameter from the authorization response. */ callbackIssuer?: string; scope?: string; resourceMetadataUrl?: URL; fetchFn?: FetchFunction; }): Promise; //#endregion //#region src/tool/mcp-transport.d.ts /** * Transport interface for MCP (Model Context Protocol) communication. * Maps to the `Transport` interface in the MCP spec. */ type MCPTransportSendOptions = { /** * Cancels the transport operation for this message. */ signal?: AbortSignal; /** * Request-specific HTTP headers produced from MCP tool parameters. */ headers?: Record; /** * Associates an outgoing message with an incoming request. */ relatedRequestId?: string | number; /** * Resumes a previously interrupted request. */ resumptionToken?: string; /** * Receives updated resumption tokens from transports that support them. */ onresumptiontoken?: (token: string) => void; }; type MCPTransportCloseOptions = { /** * Cancels transport cleanup. */ signal?: AbortSignal; }; interface MCPTransport { /** * Whether this transport can probe for stateless MCP protocol versions. * * Custom transports default to the legacy initialization flow unless they * explicitly opt in. */ supportsProtocolVersionDiscovery?: boolean; /** * Whether this transport mirrors x-mcp-header tool parameters into request * headers. */ supportsMcpToolParameterHeaders?: boolean; /** * Initialize and start the transport */ start(): Promise; /** * Send a JSON-RPC message through the transport * @param message The JSON-RPC message to send * @param options Optional request-scoped cancellation options */ send(message: JSONRPCMessage, options?: MCPTransportSendOptions): Promise; /** * Clean up and close the transport * @param options Optional cancellation options for transport cleanup */ close(options?: MCPTransportCloseOptions): Promise; /** * Event handler for transport closure */ onclose?: () => void; /** * Event handler for transport errors */ onerror?: (error: Error) => void; /** * Event handler for received messages */ onmessage?: (message: JSONRPCMessage) => void; /** * The protocol version negotiated during initialization. */ protocolVersion?: string; /** * Set the protocol version negotiated during initialization. */ setProtocolVersion?(version: string): void; } type MCPTransportConfig = { type: 'sse' | 'http'; /** * The URL of the MCP server. */ url: string; /** * Additional HTTP headers to be sent with requests. */ headers?: Record; /** * An optional OAuth client provider to use for authentication for MCP servers. */ authProvider?: OAuthClientProvider; /** * Controls how HTTP redirects are handled for transport requests. * - `'follow'`: Follow redirects automatically (standard fetch behavior). * - `'error'`: Reject any redirect response with an error. * @default 'error' */ redirect?: 'follow' | 'error'; /** * Initial MCP session id to send with resumed Streamable HTTP requests after * initialization. * Only used by the HTTP transport. */ initialSessionId?: string; /** * Initial MCP protocol version to send before initialize negotiates one. * Only used by the HTTP transport. */ initialProtocolVersion?: string; /** * Called when the Streamable HTTP server creates, changes, or clears the MCP * session id. * Only used by the HTTP transport. */ onSessionIdChange?: (sessionId: string | undefined) => void; /** * Called when a Streamable HTTP request returns 404 for an existing MCP * session id. The transport clears the session id before reporting the * underlying HTTP error. * Only used by the HTTP transport. */ onSessionExpired?: (sessionId: string) => void; /** * Whether close() should send DELETE for the current MCP session id. * Set to false when the application intends to reattach to the session later. * Only used by the HTTP transport. * @default true */ terminateSessionOnClose?: boolean; /** * Optional custom fetch implementation to use for HTTP requests. * Useful for runtimes that need a request-local fetch. * @default globalThis.fetch */ fetch?: FetchFunction; }; //#endregion //#region src/tool/mcp-client.d.ts interface MCPClientConfig { /** Experimental events: choose a private durable store or a managed adapter. */ experimental_events?: MCPEventsConfig; /** Transport configuration for connecting to the MCP server */ transport: MCPTransportConfig | MCPTransport; /** * Whether transports that support stateless protocol discovery should probe * with `server/discover` before falling back to legacy initialization. * * Disable this for legacy servers that require `initialize` to be the first * request. * * @default true */ protocolVersionDiscovery?: boolean; /** * Options that bound or cancel transport startup and the initialize request. */ initializationOptions?: RequestOptions; /** Optional callback for uncaught errors */ onUncaughtError?: (error: unknown) => void; /** * Maximum number of retries for transient MCP tool call failures. * * Set to 0 to disable retries. Retries only apply to tools/call requests. * JSON-RPC application errors, such as invalid params, are not retried. * * @default 0 */ maxRetries?: number; /** * Initialize result from a previous MCP session. When provided, the client * starts the transport and reuses this metadata without sending a new * initialize request. */ initialInitializeResult?: InitializeResult; /** Optional client name, defaults to 'ai-sdk-mcp-client' */ clientName?: string; /** * Optional client name, defaults to 'ai-sdk-mcp-client' * * @deprecated Use `clientName` instead. */ name?: string; /** Optional client version, defaults to '1.0.0' */ version?: string; /** * Optional client capabilities to advertise during initialization * * NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server */ capabilities?: ClientCapabilities; } type ManagedMCPClient = Omit & { readonly experimental_events: ManagedMCPEvents; }; export declare function createMCPClient(config: MCPClientConfig & { experimental_events: { adapter: MCPEventAdapter; }; }): Promise; export declare function createMCPClient(config: MCPClientConfig & { experimental_events?: { adapter?: never; }; }): Promise; export declare function createMCPClient(config: MCPClientConfig): Promise; interface MCPClient { /** Experimental event discovery and webhook subscription lifecycle. */ readonly experimental_events: MCPEvents; /** * Information about the connected MCP server, as reported during initialization. * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation */ readonly serverInfo: Configuration; /** * The full initialize result used by this client, either from the server * during initialization or from `initialInitializeResult`. */ readonly initializeResult: InitializeResult; /** * Optional instructions provided by the server during the initialize handshake. * * These describe how to use the server and its features, and can be used by clients * to improve LLM interactions (e.g. by including them in the system prompt). * * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#initializeresult */ readonly instructions?: string; tools(options?: { schemas?: TOOL_SCHEMAS; }): Promise>; /** * Lists available tools from the MCP server. */ listTools(options?: { params?: PaginatedRequest['params']; options?: RequestOptions; }): Promise; /** * Calls a tool on the MCP server. */ callTool(args: { name: string; arguments?: Record; options?: RequestOptions; }): Promise; /** * Creates AI SDK tools from tool definitions. */ toolsFromDefinitions(definitions: ListToolsResult, options?: { schemas?: TOOL_SCHEMAS; }): McpToolSet; listResources(options?: { params?: PaginatedRequest['params']; options?: RequestOptions; }): Promise; readResource(args: { uri: string; options?: RequestOptions; }): Promise; listResourceTemplates(options?: { options?: RequestOptions; }): Promise; experimental_listPrompts(options?: { params?: PaginatedRequest['params']; options?: RequestOptions; }): Promise; experimental_getPrompt(args: { name: string; arguments?: Record; options?: RequestOptions; }): Promise; complete(args: CompleteRequestParams & { options?: RequestOptions; }): Promise; onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise | ElicitResult): void; close: () => Promise; } //#endregion //#region src/tool/mcp-apps.d.ts /** * MIME type for HTML resources that are meant to be rendered as MCP Apps. */ export declare const MCP_APP_MIME_TYPE: "text/html;profile=mcp-app"; /** * Client capabilities to pass to `createMCPClient` when the host supports MCP Apps. */ export declare const mcpAppClientCapabilities: { readonly extensions: { readonly "io.modelcontextprotocol/ui": { readonly mimeTypes: readonly ["text/html;profile=mcp-app"]; }; }; }; /** * Content security policy metadata requested by an MCP App resource. */ type MCPAppResourceCSP = { connectDomains?: string[]; resourceDomains?: string[]; frameDomains?: string[]; [key: string]: unknown; }; /** * Host rendering metadata from an MCP App resource. */ type MCPAppResourceMeta = { prefersBorder?: boolean; csp?: MCPAppResourceCSP; permissions?: Record; [key: string]: unknown; }; /** * HTML and metadata needed by a host to render an MCP App. */ type MCPAppResource = { uri: string; mimeType: typeof MCP_APP_MIME_TYPE; html: string; meta?: MCPAppResourceMeta; }; /** * Splits tool definitions into model-visible tools and app-visible tools. */ export declare function splitMCPAppTools(definitions: ListToolsResult): { modelVisible: ListToolsResult; appVisible: ListToolsResult; }; /** * Reads a `ui://` resource from an MCP server and normalizes it for rendering. */ export declare function readMCPAppResource({ client, uri, options }: { client: Pick; uri: string; options?: RequestOptions; }): Promise; //#endregion //#region src/tool/mcp-app-fingerprint.d.ts /** * Stable SHA-256 digest (base64url) over an MCP App resource's `html`, `csp`, * and `permissions`. * * Capture a baseline on first load and compare later reads with * {@link detectMCPAppResourceDrift} to detect a changed resource. Baseline * storage and the response are the host's concern, mirroring `fingerprintTools`. */ export declare function fingerprintMCPAppResource(resource: MCPAppResource): Promise; /** * Compares two fingerprints from {@link fingerprintMCPAppResource}. Returns * `true` when the current resource differs from its baseline. */ export declare function detectMCPAppResourceDrift(current: string, baseline: string): boolean; //#endregion //#region src/error/mcp-client-error.d.ts declare const symbol: unique symbol; /** * An error occurred with the MCP client. */ export declare class MCPClientError extends AISDKError { private readonly [symbol]; readonly data?: unknown; /** * JSON-RPC error code from the server response, per the JSON-RPC 2.0 * spec (e.g. `-32601` method-not-found, `-32602` invalid-params, or * MCP-specific codes such as `-32002` resource-not-found). This is the * application-level error code populated from `error.code` in the * server's JSON-RPC error payload. Distinct from `statusCode`, which * is the HTTP transport status. */ readonly code?: number; /** * HTTP status code from the failed response, when the error originated * from an HTTP-based transport. Undefined for stdio transport * errors and for failures that do not have an associated response * status (e.g. network errors, abort). Distinct from `code`, which is * the JSON-RPC application error code. */ readonly statusCode?: number; /** * URL of the MCP endpoint the failing request was sent to, when the * error originated from an HTTP transport failure. */ readonly url?: string; /** * Body of the failing HTTP response, decoded as text, when available. * Undefined when the body could not be read or the error did not have * an associated response. */ readonly responseBody?: string; constructor({ name, message, cause, data, code, statusCode, url, responseBody }: { name?: string; message: string; cause?: unknown; data?: unknown; code?: number; statusCode?: number; url?: string; responseBody?: string; }); static isInstance(error: unknown): error is MCPClientError; } //#endregion //#region src/tool/mcp-event-webhook.d.ts type MCPEventWebhookOptions = { store: MCPEventStore; /** * Optionally validate event data using an application schema or the server's * payloadSchema. Throw to reject the payload with 400 before onEvent runs. * The event envelope and signature are always checked. */ validatePayload?: (args: { definition: MCPEventDefinition; data: MCPEvent['data']; }) => void | PromiseLike; /** * Resolve only after durable acceptance or successful processing. Deliveries * may be duplicated or reordered; deduplicate by subscription ID + eventId. * Throw to return 503 so the server can retry. The helper does not run agents. */ onEvent: (args: { subscription: MCPEventSubscriptionInfo; event: MCPEvent; }) => Promise; /** * Handles a signed replay gap: some events are no longer available. Reconcile * application state or notify the agent, then resolve after durable acceptance. * The helper saves the fresh cursor and truncated flag; delivery continues. * Throw to return 503 without changing saved state. Deduplicate by subscription * ID + messageId. */ onGap?: (args: { subscription: MCPEventSubscriptionInfo; messageId: string; gap: Extract; }) => Promise; /** * Handles signed termination: the server has ended the subscription. Inspect * termination.error and notify the agent, then resolve after durable acceptance. * The helper removes the saved subscription after this callback succeeds. * Throw to return 503 without changing saved state. Deduplicate by subscription * ID + messageId. */ onTerminated?: (args: { subscription: MCPEventSubscriptionInfo; messageId: string; termination: Extract; }) => Promise; onError?: (error: unknown) => void; }; /** * Create a Web Request/Response handler for MCP webhook deliveries. Mount it * at the callback URL before subscribing. Verification is enabled automatically * using the pending delivery secret saved by the client's subscribe method. */ declare function createMCPEventWebhook({ store, validatePayload, onEvent, onGap, onTerminated, onError }: MCPEventWebhookOptions): (request: Request) => Promise; //#endregion export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, type ElicitationRequest, type ListEventsResult as Experimental_ListEventsResult, type MCPEvent as Experimental_MCPEvent, type MCPEventAdapter as Experimental_MCPEventAdapter, type MCPEventControl as Experimental_MCPEventControl, type MCPEventDefinition as Experimental_MCPEventDefinition, type MCPEventOperations as Experimental_MCPEventOperations, type MCPEventStore as Experimental_MCPEventStore, type MCPEventSubscription as Experimental_MCPEventSubscription, type MCPEventSubscriptionInfo as Experimental_MCPEventSubscriptionInfo, type MCPEventWebhookOptions as Experimental_MCPEventWebhookOptions, type MCPEvents as Experimental_MCPEvents, type MCPEventsConfig as Experimental_MCPEventsConfig, type ManagedMCPClient as Experimental_ManagedMCPClient, type ManagedMCPEvents as Experimental_ManagedMCPEvents, type ManagedSubscribeInput as Experimental_ManagedSubscribeInput, type ManagedSubscription as Experimental_ManagedSubscription, type SubscribeEventOptions as Experimental_SubscribeEventOptions, type SubscribeEventResult as Experimental_SubscribeEventResult, type InitializeResult, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPAppResource, type MCPAppResourceCSP, type MCPAppResourceMeta, type MCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as MCPClientCapabilities, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig, type MCPClientConfig as experimental_MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type McpProviderMetadata, type McpToolAnnotations, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, createMCPClient as experimental_createMCPClient, createMCPEventWebhook as experimental_createMCPEventWebhook }; //# sourceMappingURL=index.d.ts.map