import { d as IntegrationConnectorCategory, g as IntegrationDataClass, f as IntegrationActionRisk, j as IntegrationProvider, b as IntegrationConnector } from './core-types-DMDmeutI.js';
import { M as McpCatalogTool } from './importers-BAVOQvUf.js';
import './types-eAvAgnKr.js';

/**
 * Live MCP connector — attach a remote MCP (Model Context Protocol) server
 * as an {@link IntegrationProvider}, so its tools flow through the same
 * catalog / grants / approvals machinery as every other connector instead of
 * forming a parallel, ungoverned tool path.
 *
 * Transport is Streamable HTTP only (single POST endpoint, JSON or SSE
 * response framing) — this package runs in edge workers, so stdio servers are
 * out of scope; front them with any HTTP-bridging MCP host.
 *
 * Discovery reuses {@link importMcpConnector}: `tools/list` output becomes an
 * `IntegrationConnector` whose per-action risk comes from MCP tool
 * annotations (readOnlyHint / destructiveHint) with a text-heuristic
 * fallback, so non-read MCP tools default to `approvalRequired` — fail-closed
 * against servers that don't annotate.
 *
 * Credentials: the server's auth header is supplied at construction by the
 * product (which owns secret storage) and held in memory only. Connection
 * rows carry no MCP secrets.
 */

/** Protocol revision sent on `initialize` and the `MCP-Protocol-Version`
 *  header. Servers negotiate down from this. */
declare const MCP_PROTOCOL_VERSION = "2025-06-18";
interface McpServerConfig {
    /** The server's single Streamable-HTTP endpoint. */
    url: string;
    /** Static request headers — typically `{ Authorization: 'Bearer …' }`.
     *  Held in memory only; never persisted by this module. */
    headers?: Record<string, string>;
    protocolVersion?: string;
    clientInfo?: {
        name: string;
        version: string;
    };
    /** Injectable for tests / custom egress policies (SSRF pinning). */
    fetchImpl?: typeof fetch;
}
interface McpToolCallResult {
    /** MCP content blocks (text, image, resource, …) verbatim. */
    content: unknown[];
    isError: boolean;
    /** `structuredContent` from servers that return it. */
    structured?: unknown;
}
/**
 * Minimal Streamable-HTTP MCP client: `initialize` handshake (capturing the
 * server's `Mcp-Session-Id`), paginated `tools/list`, and `tools/call`.
 * Lazily initializes on first use; safe to share across calls within an
 * isolate.
 */
declare class McpHttpClient {
    private readonly config;
    private nextId;
    private sessionId;
    private negotiatedVersion;
    private initializing;
    constructor(config: McpServerConfig);
    private get fetchImpl();
    private post;
    private request;
    /** Idempotent handshake; concurrent callers share one in-flight init. */
    initialize(): Promise<void>;
    /** Full tool catalog, following `nextCursor` pagination. */
    listTools(): Promise<McpCatalogTool[]>;
    callTool(name: string, args: unknown): Promise<McpToolCallResult>;
}
interface CreateMcpProviderOptions {
    /** Provider id, unique within the hub (e.g. `mcp:linear`). */
    id: string;
    server: McpServerConfig;
    connectorId: string;
    connectorTitle: string;
    category?: IntegrationConnectorCategory;
    scopes?: string[];
    dataClass?: IntegrationDataClass;
    /** Risk for tools whose annotations/name don't classify them. Defaults to
     *  'write' (⇒ approvalRequired) — fail-closed. */
    defaultRisk?: IntegrationActionRisk;
}
/** Discover a live MCP server's tools as an {@link IntegrationConnector}. */
declare function discoverMcpConnector(client: McpHttpClient, options: CreateMcpProviderOptions): Promise<IntegrationConnector>;
/**
 * Build an {@link IntegrationProvider} over one remote MCP server: live
 * `tools/list` discovery at construction, `tools/call` on invoke. A tool
 * result with `isError` maps to `{ ok: false }` (the model sees the failure
 * content); transport and JSON-RPC failures throw {@link IntegrationError}.
 */
declare function createMcpProvider(options: CreateMcpProviderOptions): Promise<IntegrationProvider>;

export { type CreateMcpProviderOptions, MCP_PROTOCOL_VERSION, McpHttpClient, type McpServerConfig, type McpToolCallResult, createMcpProvider, discoverMcpConnector };
