/**
 * Model Context Protocol (MCP) server for Apify Actors
 */
import type { TaskStore } from '@modelcontextprotocol/sdk/experimental/tasks/interfaces.js';
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
import { ApifyClient } from '../apify_client.js';
import type { ActorsMcpServerOptions, ActorStore, ServerMode, ToolEntry } from '../types.js';
/**
 * Create Apify MCP server
 */
export declare class ActorsMcpServer {
    readonly server: Server;
    readonly tools: Map<string, ToolEntry>;
    private toolsChangedHandler;
    private sigintHandler;
    private currentLogLevel;
    readonly options: ActorsMcpServerOptions;
    readonly taskStore: TaskStore;
    readonly actorStore?: ActorStore;
    /** Resolved server mode — normalized once at construction from options.uiMode. */
    readonly serverMode: ServerMode;
    /** Mode-specific executor for direct actor tools (`type: 'actor'`). */
    private readonly actorExecutor;
    private telemetryEnabled;
    private telemetryEnv;
    private availableWidgets;
    /**
     * Whether the connected client advertises MCP Apps UI support (`io.modelcontextprotocol/ui` extension).
     * NOTE: This is currently informational only (logged for observability) and does not yet gate widget behavior.
     */
    clientSupportsUi: boolean;
    constructor(options?: ActorsMcpServerOptions);
    /**
     * Telemetry configuration with precedence: explicit options > env vars > defaults
     */
    private setupTelemetry;
    /**
     * Detects MCP Apps UI support from client capabilities after initialization.
     * Checks for the `io.modelcontextprotocol/ui` extension with `text/html;profile=mcp-app` MIME type.
     */
    private setupCapabilityNegotiation;
    /**
     * Returns an array of tool names.
     * @returns {string[]} - An array of tool names.
     */
    listToolNames(): string[];
    /**
    * Register handler to get notified when tools change.
    * The handler receives an array of tool names that the server has after the change.
    * This is primarily used to store the tools in shared state (e.g., Redis) for recovery
    * when the server loses local state.
    * @throws {Error} - If a handler is already registered.
    * @param handler - The handler function to be called when tools change.
    */
    registerToolsChangedHandler(handler: (toolNames: string[]) => void): void;
    /**
    * Unregister the handler for tools changed event.
    * @throws {Error} - If no handler is currently registered.
    */
    unregisterToolsChangedHandler(): void;
    /**
     * Returns the list of all internal tool names
     * @returns {string[]} - Array of loaded tool IDs (e.g., 'apify/rag-web-browser')
     */
    private listInternalToolNames;
    /**
     * Returns the list of all currently loaded Actor tool IDs.
     * @returns {string[]} - Array of loaded Actor tool IDs (e.g., 'apify/rag-web-browser')
     */
    listActorToolNames(): string[];
    /**
     * Returns a list of Actor IDs that are registered as MCP servers.
     * @returns {string[]} - An array of Actor MCP server Actor IDs (e.g., 'apify/actors-mcp-server').
     */
    private listActorMcpServerToolIds;
    /**
     * Returns a list of Actor name and MCP server tool IDs.
     * @returns {string[]} - An array of Actor MCP server Actor IDs (e.g., 'apify/actors-mcp-server').
     */
    listAllToolNames(): string[];
    /**
    * Loads missing toolNames from a provided list of tool names.
    * Skips toolNames that are already loaded and loads only the missing ones.
    * @param toolNames - Array of tool names to ensure are loaded
    * @param apifyClient
    */
    loadToolsByName(toolNames: string[], apifyClient: ApifyClient): Promise<void>;
    /**
     * Load actors as tools, upsert them to the server, and return the tool entries.
     * This is a public method that wraps getActorsAsTools and handles the upsert operation.
     * @param actorIdsOrNames - Array of actor IDs or names to load as tools
     * @param apifyClient
     * @returns Promise<ToolEntry[]> - Array of loaded tool entries
     */
    loadActorsAsTools(actorIdsOrNames: string[], apifyClient: ApifyClient): Promise<ToolEntry[]>;
    /**
     * Loads tools from URL params.
     *
     * This method also handles enabling of Actor autoloading via the processParamsGetTools.
     *
     * Used primarily for SSE.
     */
    loadToolsFromUrl(url: string, apifyClient: ApifyClient): Promise<void>;
    /** Delete tools from the server and notify the handler.
     */
    removeToolsByName(toolNames: string[], shouldNotifyToolsChangedHandler?: boolean): string[];
    /**
     * Upsert new tools.
     * @param tools - Array of tool wrappers to add or update
     * @param shouldNotifyToolsChangedHandler - Whether to notify the tools changed handler
     * @returns Array of added/updated tool wrappers
     */
    upsertTools(tools: ToolEntry[], shouldNotifyToolsChangedHandler?: boolean): ToolEntry[];
    private notifyToolsChangedHandler;
    private removeToolByName;
    private setupErrorHandling;
    private setupLoggingProxy;
    private setupLoggingHandlers;
    private setupResourceHandlers;
    /**
     * Sets up MCP request handlers for prompts.
     */
    private setupPromptHandlers;
    /**
      * Sets up MCP request handlers for long-running tasks.
      */
    private setupTaskHandlers;
    private setupToolHandlers;
    /**
     * Finalizes and tracks telemetry for a tool call.
     * Calculates execution time, sets final status, and sends the telemetry event.
     *
     * @param telemetryData - Telemetry data to finalize and track (null if telemetry is disabled)
     * @param userId - Apify user ID (string or null if not available)
     * @param startTime - Timestamp when the tool call started
     * @param toolStatus - Final status of the tool call
     */
    private finalizeAndTrackTelemetry;
    /**
     * Executes a tool asynchronously for a long-running task and updates task status.
     *
     * @param params - Tool execution parameters
     * @param params.taskId - The task identifier
     * @param params.tool - The tool to execute
     * @param params.args - Tool arguments
     * @param params.apifyToken - Apify API token
     * @param params.progressToken - Progress token for notifications
     * @param params.extra - Extra request handler context
     * @param params.mcpSessionId - MCP session ID for telemetry
     */
    private executeToolAndUpdateTask;
    private prepareTelemetryData;
    /**
     * Resolves widgets and determines which ones are ready to be served.
     */
    private resolveWidgets;
    connect(transport: Transport): Promise<void>;
    close(): Promise<void>;
}
//# sourceMappingURL=server.d.ts.map