import { FetchFunction, FlexibleSchema, Tool, ToolExecutionOptions } from "@ai-sdk/provider-utils";
import { z } from "zod/v4";
import { AISDKError, JSONObject } from "@ai-sdk/provider";
//#region src/tool/json-rpc-message.d.ts
declare const JSONRPCRequestSchema: z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
  method: z.ZodString;
  params: z.ZodOptional<z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
}, z.core.$strict>;
type JSONRPCRequest = z.infer<typeof JSONRPCRequestSchema>;
declare const JSONRPCResponseSchema: z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
  result: z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    resultType: z.ZodOptional<z.ZodString>;
  }, z.core.$loose>;
}, z.core.$strict>;
type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
declare const JSONRPCErrorSchema: z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
  error: z.ZodObject<{
    code: z.ZodNumber;
    message: z.ZodString;
    data: z.ZodOptional<z.ZodUnknown>;
  }, z.core.$strip>;
}, z.core.$strict>;
type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
declare const JSONRPCNotificationSchema: z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  method: z.ZodString;
  params: z.ZodOptional<z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
}, z.core.$strict>;
type JSONRPCNotification = z.infer<typeof JSONRPCNotificationSchema>;
declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
  method: z.ZodString;
  params: z.ZodOptional<z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
}, z.core.$strict>, z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  method: z.ZodString;
  params: z.ZodOptional<z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
}, z.core.$strict>, z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
  result: z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    resultType: z.ZodOptional<z.ZodString>;
  }, z.core.$loose>;
}, z.core.$strict>, z.ZodObject<{
  jsonrpc: z.ZodLiteral<"2.0">;
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
  error: z.ZodObject<{
    code: z.ZodNumber;
    message: z.ZodString;
    data: z.ZodOptional<z.ZodUnknown>;
  }, z.core.$strip>;
}, z.core.$strict>]>;
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
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<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
type ToolMeta = z.infer<typeof ToolMetaSchema>;
type ToolSchemas = Record<string, {
  inputSchema: FlexibleSchema<JSONObject | unknown>;
  outputSchema?: FlexibleSchema<JSONObject | unknown>;
}> | 'automatic' | undefined;
/** Base MCP tool type with execute and _meta */
type McpToolBase<INPUT = unknown, OUTPUT = CallToolResult> = Tool<INPUT, OUTPUT> & {
  execute: (input: INPUT, options?: ToolExecutionOptions<{}>) => ReturnType<NonNullable<Tool<INPUT, OUTPUT>['execute']>>;
  _meta?: ToolMeta;
};
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
  inputSchema: FlexibleSchema<any>;
  outputSchema?: FlexibleSchema<any>;
}> ? { [K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
  inputSchema: FlexibleSchema<infer INPUT>;
  outputSchema: FlexibleSchema<infer OUTPUT>;
} ? McpToolBase<INPUT, OUTPUT> : TOOL_SCHEMAS[K] extends {
  inputSchema: FlexibleSchema<infer INPUT>;
} ? McpToolBase<INPUT, CallToolResult> : never; } : Record<string, McpToolBase<unknown, CallToolResult>>;
declare const ClientOrServerImplementationSchema: z.ZodObject<{
  name: z.ZodString;
  version: z.ZodString;
  title: z.ZodOptional<z.ZodString>;
}, z.core.$loose>;
type Configuration = z.infer<typeof ClientOrServerImplementationSchema>;
declare const BaseParamsSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
}, z.core.$loose>;
type BaseParams = z.infer<typeof BaseParamsSchema>;
declare const RequestSchema: z.ZodObject<{
  method: z.ZodString;
  params: z.ZodOptional<z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  }, z.core.$loose>>;
}, z.core.$strip>;
type Request$1 = z.infer<typeof RequestSchema>;
type RequestOptions = {
  signal?: AbortSignal;
  timeout?: number;
  maxTotalTimeout?: number;
};
declare const ClientCapabilitiesSchema: z.ZodObject<{
  elicitation: z.ZodOptional<z.ZodObject<{
    applyDefaults: z.ZodOptional<z.ZodBoolean>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
declare const InitializeResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  protocolVersion: z.ZodString;
  capabilities: z.ZodObject<{
    events: z.ZodOptional<z.ZodNullable<z.ZodObject<{
      listChanged: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
    }, z.core.$loose>>>;
    experimental: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    logging: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    completions: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    prompts: z.ZodOptional<z.ZodObject<{
      listChanged: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$loose>>;
    resources: z.ZodOptional<z.ZodObject<{
      subscribe: z.ZodOptional<z.ZodBoolean>;
      listChanged: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$loose>>;
    tools: z.ZodOptional<z.ZodObject<{
      listChanged: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$loose>>;
    elicitation: z.ZodOptional<z.ZodObject<{
      applyDefaults: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$loose>>;
  }, z.core.$loose>;
  serverInfo: z.ZodObject<{
    name: z.ZodString;
    version: z.ZodString;
    title: z.ZodOptional<z.ZodString>;
  }, z.core.$loose>;
  instructions: z.ZodOptional<z.ZodString>;
}, z.core.$loose>;
type InitializeResult = z.infer<typeof InitializeResultSchema>;
type PaginatedRequest = Request$1 & {
  params?: BaseParams & {
    cursor?: string;
  };
};
declare const ListToolsResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  nextCursor: z.ZodOptional<z.ZodString>;
  tools: z.ZodArray<z.ZodObject<{
    name: z.ZodString;
    title: z.ZodOptional<z.ZodString>;
    description: z.ZodOptional<z.ZodString>;
    inputSchema: z.ZodObject<{
      type: z.ZodOptional<z.ZodUnknown>;
      properties: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    }, z.core.$loose>;
    outputSchema: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    annotations: z.ZodOptional<z.ZodObject<{
      title: z.ZodOptional<z.ZodString>;
      readOnlyHint: z.ZodOptional<z.ZodBoolean>;
      destructiveHint: z.ZodOptional<z.ZodBoolean>;
      idempotentHint: z.ZodOptional<z.ZodBoolean>;
      openWorldHint: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$loose>>;
    _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
declare const ListResourcesResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  nextCursor: z.ZodOptional<z.ZodString>;
  resources: z.ZodArray<z.ZodObject<{
    uri: z.ZodString;
    name: z.ZodString;
    title: z.ZodOptional<z.ZodString>;
    description: z.ZodOptional<z.ZodString>;
    mimeType: z.ZodOptional<z.ZodString>;
    size: z.ZodOptional<z.ZodNumber>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type ListResourcesResult = z.infer<typeof ListResourcesResultSchema>;
declare const CallToolResultSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
    type: z.ZodLiteral<"text">;
    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<readonly [z.ZodObject<{
      uri: z.ZodString;
      name: z.ZodOptional<z.ZodString>;
      title: z.ZodOptional<z.ZodString>;
      mimeType: z.ZodOptional<z.ZodString>;
      text: z.ZodString;
    }, z.core.$loose>, z.ZodObject<{
      uri: z.ZodString;
      name: z.ZodOptional<z.ZodString>;
      title: z.ZodOptional<z.ZodString>;
      mimeType: z.ZodOptional<z.ZodString>;
      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<z.ZodString>;
    mimeType: z.ZodOptional<z.ZodString>;
  }, z.core.$loose>, z.ZodObject<{
    type: z.ZodString;
  }, z.core.$loose>]>>;
  structuredContent: z.ZodOptional<z.ZodUnknown>;
  isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
}, z.core.$loose>, z.ZodPipe<z.ZodPipe<z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  content: z.ZodOptional<z.ZodNever>;
  structuredContent: z.ZodJSONSchema;
  isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
}, z.core.$loose>, z.ZodTransform<{
  [x: string]: unknown;
  content: ({
    [x: string]: unknown;
    type: string;
  } | {
    [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;
  })[];
  _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<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
    type: z.ZodLiteral<"text">;
    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<readonly [z.ZodObject<{
      uri: z.ZodString;
      name: z.ZodOptional<z.ZodString>;
      title: z.ZodOptional<z.ZodString>;
      mimeType: z.ZodOptional<z.ZodString>;
      text: z.ZodString;
    }, z.core.$loose>, z.ZodObject<{
      uri: z.ZodString;
      name: z.ZodOptional<z.ZodString>;
      title: z.ZodOptional<z.ZodString>;
      mimeType: z.ZodOptional<z.ZodString>;
      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<z.ZodString>;
    mimeType: z.ZodOptional<z.ZodString>;
  }, z.core.$loose>, z.ZodObject<{
    type: z.ZodString;
  }, z.core.$loose>]>>;
  structuredContent: z.ZodOptional<z.ZodUnknown>;
  isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
}, z.core.$loose>>]>, z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  toolResult: z.ZodNonOptional<z.ZodUnknown>;
}, z.core.$loose>]>;
type CallToolResult = z.infer<typeof CallToolResultSchema>;
declare const ListResourceTemplatesResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  resourceTemplates: z.ZodArray<z.ZodObject<{
    uriTemplate: z.ZodString;
    name: z.ZodString;
    title: z.ZodOptional<z.ZodString>;
    description: z.ZodOptional<z.ZodString>;
    mimeType: z.ZodOptional<z.ZodString>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type ListResourceTemplatesResult = z.infer<typeof ListResourceTemplatesResultSchema>;
declare const ReadResourceResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
    uri: z.ZodString;
    name: z.ZodOptional<z.ZodString>;
    title: z.ZodOptional<z.ZodString>;
    mimeType: z.ZodOptional<z.ZodString>;
    text: z.ZodString;
  }, z.core.$loose>, z.ZodObject<{
    uri: z.ZodString;
    name: z.ZodOptional<z.ZodString>;
    title: z.ZodOptional<z.ZodString>;
    mimeType: z.ZodOptional<z.ZodString>;
    blob: z.ZodBase64;
  }, z.core.$loose>]>>;
}, z.core.$loose>;
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
declare const CompleteRequestParamsSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  ref: z.ZodUnion<readonly [z.ZodObject<{
    type: z.ZodLiteral<"ref/prompt">;
    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.ZodObject<{
    arguments: z.ZodRecord<z.ZodString, z.ZodString>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type CompleteRequestParams = z.infer<typeof CompleteRequestParamsSchema>;
declare const CompleteResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  completion: z.ZodObject<{
    values: z.ZodArray<z.ZodString>;
    total: z.ZodOptional<z.ZodNumber>;
    hasMore: z.ZodOptional<z.ZodBoolean>;
  }, z.core.$loose>;
}, z.core.$loose>;
type CompleteResult = z.infer<typeof CompleteResultSchema>;
declare const ListPromptsResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  nextCursor: z.ZodOptional<z.ZodString>;
  prompts: z.ZodArray<z.ZodObject<{
    name: z.ZodString;
    title: z.ZodOptional<z.ZodString>;
    description: z.ZodOptional<z.ZodString>;
    arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
      name: z.ZodString;
      description: z.ZodOptional<z.ZodString>;
      required: z.ZodOptional<z.ZodBoolean>;
    }, z.core.$loose>>>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
declare const GetPromptResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  description: z.ZodOptional<z.ZodString>;
  messages: z.ZodArray<z.ZodObject<{
    role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
    content: z.ZodUnion<readonly [z.ZodObject<{
      type: z.ZodLiteral<"text">;
      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<readonly [z.ZodObject<{
        uri: z.ZodString;
        name: z.ZodOptional<z.ZodString>;
        title: z.ZodOptional<z.ZodString>;
        mimeType: z.ZodOptional<z.ZodString>;
        text: z.ZodString;
      }, z.core.$loose>, z.ZodObject<{
        uri: z.ZodString;
        name: z.ZodOptional<z.ZodString>;
        title: z.ZodOptional<z.ZodString>;
        mimeType: z.ZodOptional<z.ZodString>;
        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<z.ZodString>;
      mimeType: z.ZodOptional<z.ZodString>;
    }, z.core.$loose>]>;
  }, z.core.$loose>>;
}, z.core.$loose>;
type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
export declare const ElicitationRequestSchema: z.ZodObject<{
  method: z.ZodLiteral<"elicitation/create">;
  params: z.ZodObject<{
    _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
    message: z.ZodString;
    requestedSchema: z.ZodUnknown;
  }, z.core.$loose>;
}, z.core.$strip>;
type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
export declare const ElicitResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
  content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$loose>;
type ElicitResult = z.infer<typeof ElicitResultSchema>;
//#endregion
//#region src/tool/mcp-event-types.d.ts
declare const MCPEventDefinitionSchema: z.ZodObject<{
  name: z.ZodString;
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
  delivery: z.ZodArray<z.ZodEnum<{
    webhook: "webhook";
    poll: "poll";
    push: "push";
  }>>;
  inputSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
  payloadSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
}, z.core.$loose>;
type MCPEventDefinition = z.infer<typeof MCPEventDefinitionSchema>;
declare const ListEventsResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  events: z.ZodArray<z.ZodObject<{
    name: z.ZodString;
    description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
    delivery: z.ZodArray<z.ZodEnum<{
      webhook: "webhook";
      poll: "poll";
      push: "push";
    }>>;
    inputSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
    payloadSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
  }, z.core.$loose>>;
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, z.core.$loose>;
type ListEventsResult = z.infer<typeof ListEventsResultSchema>;
declare const SubscribeEventResultSchema: z.ZodObject<{
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
  resultType: z.ZodOptional<z.ZodString>;
  id: z.ZodString;
  refreshBefore: z.ZodNullable<z.ZodISODateTime>;
  cursor: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null | undefined>>;
  truncated: z.ZodBoolean;
}, z.core.$loose>;
type SubscribeEventResult = z.infer<typeof SubscribeEventResultSchema>;
declare const MCPEventSchema: z.ZodObject<{
  eventId: z.ZodString;
  name: z.ZodString;
  timestamp: z.ZodISODateTime;
  data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
  cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, z.core.$loose>;
type MCPEvent = z.infer<typeof MCPEventSchema>;
declare const MCPEventControlSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
  type: z.ZodLiteral<"gap">;
  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.ZodNullable<z.ZodUnknown>>;
  }, z.core.$loose>;
}, z.core.$loose>], "type">, 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<typeof MCPEventControlSchema>;
/** 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<MCPEventSubscription | undefined>;
  getById(id: string): Promise<MCPEventSubscription | undefined>;
  set(subscription: MCPEventSubscription): Promise<void>;
  update(key: string, patch: Partial<MCPEventSubscription>): Promise<void>;
  delete(key: string): Promise<void>;
}
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<void>;
} | {
  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<ListEventsResult>;
  subscribe(options: SubscribeEventOptions): Promise<SubscribeEventResult>;
  refresh(options: MCPEventSubscriptionOptions): Promise<SubscribeEventResult>;
  unsubscribe(options: MCPEventSubscriptionOptions): Promise<void>;
}
//#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;
  /** Application lifetime in milliseconds, or null until explicitly stopped. */
  ttlMs: number | null;
  options?: RequestOptions;
};
/**
 * 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<ManagedSubscription>;
  getSubscription(input: {
    id: string;
    options?: RequestOptions;
  }): Promise<ManagedSubscription>;
  listSubscriptions(input?: {
    cursor?: string;
    limit?: number;
    status?: ManagedSubscription['status'];
    options?: RequestOptions;
  }): Promise<{
    subscriptions: ManagedSubscription[];
    nextCursor?: string;
  }>;
  unsubscribe(input: {
    id: string;
    options?: RequestOptions;
  }): Promise<ManagedSubscription>;
}
/**
 * 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<z.ZodString>;
  token_type: z.ZodString;
  expires_in: z.ZodOptional<z.ZodNumber>;
  scope: z.ZodOptional<z.ZodString>;
  refresh_token: z.ZodOptional<z.ZodString>;
  issuer: z.ZodOptional<z.ZodString>;
  authorization_server: z.ZodOptional<z.ZodString>;
  token_endpoint: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
declare const OAuthMetadataSchema: z.ZodObject<{
  issuer: z.ZodString;
  authorization_endpoint: z.ZodString;
  token_endpoint: z.ZodString;
  registration_endpoint: z.ZodOptional<z.ZodString>;
  authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
  scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  response_types_supported: z.ZodArray<z.ZodString>;
  grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, 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<z.ZodString>;
  jwks_uri: z.ZodString;
  registration_endpoint: z.ZodOptional<z.ZodString>;
  authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
  scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  response_types_supported: z.ZodArray<z.ZodString>;
  grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  subject_types_supported: z.ZodArray<z.ZodString>;
  id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
  claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$loose>;
declare const OAuthClientInformationSchema: z.ZodObject<{
  client_id: z.ZodString;
  client_secret: z.ZodOptional<z.ZodString>;
  client_id_issued_at: z.ZodOptional<z.ZodNumber>;
  client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
  issuer: z.ZodOptional<z.ZodString>;
  authorization_server: z.ZodOptional<z.ZodString>;
  token_endpoint: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
declare const OAuthClientMetadataSchema: z.ZodObject<{
  redirect_uris: z.ZodArray<z.ZodString>;
  application_type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"native">, z.ZodLiteral<"web">]>>;
  token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
  grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
  response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
  client_name: z.ZodOptional<z.ZodString>;
  client_uri: z.ZodOptional<z.ZodString>;
  logo_uri: z.ZodOptional<z.ZodString>;
  scope: z.ZodOptional<z.ZodString>;
  contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
  tos_uri: z.ZodOptional<z.ZodString>;
  policy_uri: z.ZodOptional<z.ZodString>;
  jwks_uri: z.ZodOptional<z.ZodString>;
  jwks: z.ZodOptional<z.ZodAny>;
  software_id: z.ZodOptional<z.ZodString>;
  software_version: z.ZodOptional<z.ZodString>;
  software_statement: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
//#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<OAuthTokens | undefined>;
  saveTokens(tokens: OAuthTokens): void | Promise<void>;
  redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
  saveCodeVerifier(codeVerifier: string): void | Promise<void>;
  codeVerifier(): string | Promise<string>;
  /**
   * 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<void>;
  /**
   * 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<void>;
  get redirectUrl(): string | URL;
  get clientMetadata(): OAuthClientMetadata;
  /**
   * Returns client credentials. Pre-registered confidential clients must specify
   * their authorization server's `issuer` or provide stored authorization server
   * information. `validateAuthorizationServerURL` does not replace this binding.
   */
  clientInformation(): OAuthClientInformation | undefined | Promise<OAuthClientInformation | undefined>;
  /**
   * 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<boolean>;
  saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise<void>;
  authorizationServerInformation?(): OAuthAuthorizationServerInformation | undefined | Promise<OAuthAuthorizationServerInformation | undefined>;
  saveAuthorizationServerInformation?(authorizationServerInformation: OAuthAuthorizationServerInformation): void | Promise<void>;
  /**
   * Validates an authorization server URL discovered from MCP protected resource
   * metadata before the client fetches its OAuth metadata.
   * This additional restriction does not bind client credentials to that server.
   */
  validateAuthorizationServerURL?(serverUrl: string | URL, authorizationServerUrl: string | URL): void | Promise<void>;
  state?(): string | Promise<string>;
  saveState?(state: string): void | Promise<void>;
  storedState?(): string | undefined | Promise<string | undefined>;
  /**
   * Overrides protected resource validation and selection. Return a resource URL
   * or throw to reject it. Returning undefined uses the canonical MCP server URL
   * with its fragment removed, so OAuth requests always include a resource.
   */
  validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
}
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<AuthResult>;
//#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<string, string>;
  /**
   * 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 the client waits for the `server/discover` response instead of
   * treating a slow response as a legacy server.
   *
   * Transports that always deliver a response, such as Streamable HTTP, set
   * this so a slow modern server is not downgraded to `initialize`. Other
   * transports keep a short probe timeout because a legacy server may never
   * answer the unknown method.
   */
  waitsForProtocolVersionDiscovery?: boolean;
  /**
   * Whether this transport mirrors x-mcp-header tool parameters into request
   * headers.
   */
  supportsMcpToolParameterHeaders?: boolean;
  /**
   * Initialize and start the transport
   */
  start(): Promise<void>;
  /**
   * 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<void>;
  /**
   * Clean up and close the transport
   * @param options Optional cancellation options for transport cleanup
   */
  close(options?: MCPTransportCloseOptions): Promise<void>;
  /**
   * 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<string, string>;
  /**
   * 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<MCPClient, 'experimental_events'> & {
  readonly experimental_events: ManagedMCPEvents;
};
export declare function createMCPClient(config: MCPClientConfig & {
  experimental_events: {
    adapter: MCPEventAdapter;
  };
}): Promise<ManagedMCPClient>;
export declare function createMCPClient(config: MCPClientConfig & {
  experimental_events?: {
    adapter?: never;
  };
}): Promise<MCPClient>;
export declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient | ManagedMCPClient>;
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<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
    schemas?: TOOL_SCHEMAS;
  }): Promise<McpToolSet<TOOL_SCHEMAS>>;
  /**
   * Lists available tools from the MCP server.
   */
  listTools(options?: {
    params?: PaginatedRequest['params'];
    options?: RequestOptions;
  }): Promise<ListToolsResult>;
  /**
   * Calls a tool on the MCP server.
   */
  callTool(args: {
    name: string;
    arguments?: Record<string, unknown>;
    options?: RequestOptions;
  }): Promise<CallToolResult>;
  /**
   * Creates AI SDK tools from tool definitions.
   */
  toolsFromDefinitions<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(definitions: ListToolsResult, options?: {
    schemas?: TOOL_SCHEMAS;
  }): McpToolSet<TOOL_SCHEMAS>;
  listResources(options?: {
    params?: PaginatedRequest['params'];
    options?: RequestOptions;
  }): Promise<ListResourcesResult>;
  readResource(args: {
    uri: string;
    options?: RequestOptions;
  }): Promise<ReadResourceResult>;
  listResourceTemplates(options?: {
    options?: RequestOptions;
  }): Promise<ListResourceTemplatesResult>;
  listPrompts(options?: {
    params?: PaginatedRequest['params'];
    options?: RequestOptions;
  }): Promise<ListPromptsResult>;
  getPrompt(args: {
    name: string;
    arguments?: Record<string, unknown>;
    options?: RequestOptions;
  }): Promise<GetPromptResult>;
  /** @deprecated Use `listPrompts` instead. */
  experimental_listPrompts(options?: {
    params?: PaginatedRequest['params'];
    options?: RequestOptions;
  }): Promise<ListPromptsResult>;
  /** @deprecated Use `getPrompt` instead. */
  experimental_getPrompt(args: {
    name: string;
    arguments?: Record<string, unknown>;
    options?: RequestOptions;
  }): Promise<GetPromptResult>;
  complete(args: CompleteRequestParams & {
    options?: RequestOptions;
  }): Promise<CompleteResult>;
  onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
  close: () => Promise<void>;
}
//#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[];
  baseUriDomains?: string[];
  [key: string]: unknown;
};
/**
 * Host rendering metadata from an MCP App resource.
 */
type MCPAppResourceMeta = {
  prefersBorder?: boolean;
  csp?: MCPAppResourceCSP;
  permissions?: Record<string, unknown>;
  [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<MCPClient, 'readResource'>;
  uri: string;
  options?: RequestOptions;
}): Promise<MCPAppResource>;
//#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<string>;
/**
 * 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<void>;
  /**
   * 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<void>;
  /**
   * 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<MCPEventControl, {
      type: 'gap';
    }>;
  }) => Promise<void>;
  /**
   * 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<MCPEventControl, {
      type: 'terminated';
    }>;
  }) => Promise<void>;
  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<Response>;
//#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