/**
 * @fileoverview MCP GraphQL Resolver
 *
 * Provides GraphQL mutations for MCP (Model Context Protocol) operations
 * including tool synchronization with progress streaming and OAuth management.
 */
import { PubSubEngine } from 'type-graphql';
import { AppContext } from '../types.js';
import { ResolverBase } from '../generic/ResolverBase.js';
/**
 * Input type for syncing MCP tools
 */
export declare class SyncMCPToolsInput {
    /**
     * The ID of the MCP server connection to sync tools for
     */
    ConnectionID: string;
    /**
     * Optional flag to force a full sync even if recently synced
     */
    ForceSync?: boolean;
}
/**
 * Output type for MCP tool sync results
 */
export declare class SyncMCPToolsResult {
    /**
     * Whether the sync operation succeeded
     */
    Success: boolean;
    /**
     * Error message if the operation failed
     */
    ErrorMessage?: string;
    /**
     * Number of tools newly added
     */
    Added: number;
    /**
     * Number of tools updated
     */
    Updated: number;
    /**
     * Number of tools marked as deprecated
     */
    Deprecated: number;
    /**
     * Total number of tools after sync
     */
    Total: number;
    /**
     * Name of the MCP server that was synced
     */
    ServerName?: string;
    /**
     * Connection name that was synced
     */
    ConnectionName?: string;
    /**
     * Whether OAuth authorization is required before connecting
     */
    RequiresOAuth?: boolean;
    /**
     * OAuth authorization URL if authorization is required
     */
    AuthorizationUrl?: string;
    /**
     * OAuth state parameter for tracking the authorization flow
     */
    StateParameter?: string;
    /**
     * Whether OAuth re-authorization is required
     */
    RequiresReauthorization?: boolean;
    /**
     * Reason for re-authorization if required
     */
    ReauthorizationReason?: string;
}
/**
 * Input type for executing an MCP tool
 */
export declare class ExecuteMCPToolInput {
    /**
     * The ID of the MCP server connection to use
     */
    ConnectionID: string;
    /**
     * The ID of the tool to execute (from MCP Server Tools entity)
     */
    ToolID: string;
    /**
     * The name of the tool to execute
     */
    ToolName: string;
    /**
     * JSON string of input arguments to pass to the tool
     */
    InputArgs?: string;
}
/**
 * Output type for MCP tool execution results
 */
export declare class ExecuteMCPToolResult {
    /**
     * Whether the tool execution succeeded
     */
    Success: boolean;
    /**
     * Error message if the execution failed
     */
    ErrorMessage?: string;
    /**
     * The result returned by the tool (JSON)
     */
    Result?: Record<string, unknown> | null;
    /**
     * Execution duration in milliseconds
     */
    DurationMs?: number;
}
/**
 * OAuth authorization status enum
 */
declare enum MCPOAuthStatus {
    PENDING = "PENDING",
    COMPLETED = "COMPLETED",
    FAILED = "FAILED",
    EXPIRED = "EXPIRED"
}
/**
 * Input for initiating OAuth authorization
 */
export declare class InitiateMCPOAuthInput {
    ConnectionID: string;
    AdditionalScopes?: string;
    FrontendCallbackUrl?: string;
}
/**
 * Input for checking OAuth status
 */
export declare class GetMCPOAuthStatusInput {
    StateParameter: string;
}
/**
 * Input for revoking OAuth credentials
 */
export declare class RevokeMCPOAuthInput {
    ConnectionID: string;
    Reason?: string;
}
/**
 * Input for refreshing OAuth tokens
 */
export declare class RefreshMCPOAuthTokenInput {
    ConnectionID: string;
}
/**
 * Result from initiating OAuth authorization
 */
export declare class InitiateMCPOAuthResult {
    Success: boolean;
    ErrorMessage?: string;
    AuthorizationUrl?: string;
    StateParameter?: string;
    ExpiresAt?: Date;
    UsedDynamicRegistration?: boolean;
}
/**
 * Result from checking OAuth status
 */
export declare class MCPOAuthStatusResult {
    Success: boolean;
    ErrorMessage?: string;
    Status?: MCPOAuthStatus;
    ConnectionID?: string;
    InitiatedAt?: Date;
    CompletedAt?: Date;
    AuthErrorCode?: string;
    AuthErrorDescription?: string;
    IsRetryable?: boolean;
}
/**
 * Result from revoking OAuth credentials
 */
export declare class RevokeMCPOAuthResult {
    Success: boolean;
    ErrorMessage?: string;
    ConnectionID?: string;
}
/**
 * Result from refreshing OAuth tokens
 */
export declare class RefreshMCPOAuthTokenResult {
    Success: boolean;
    ErrorMessage?: string;
    ExpiresAt?: Date;
    RequiresReauthorization?: boolean;
}
/**
 * OAuth connection status information
 */
export declare class MCPOAuthConnectionStatus {
    ConnectionID: string;
    IsOAuthEnabled: boolean;
    HasValidTokens: boolean;
    IsAccessTokenExpired?: boolean;
    TokenExpiresAt?: Date;
    HasRefreshToken?: boolean;
    RequiresReauthorization: boolean;
    ReauthorizationReason?: string;
    IssuerUrl?: string;
    GrantedScopes?: string;
}
/** PubSub topic for MCP OAuth events */
export declare const MCP_OAUTH_EVENTS_TOPIC = "MCP_OAUTH_EVENTS";
/**
 * OAuth event types for subscriptions
 */
export type MCPOAuthEventType = 'authorizationRequired' | 'authorizationCompleted' | 'tokenRefreshed' | 'tokenRefreshFailed';
/**
 * Payload interface for OAuth subscription events
 */
export interface MCPOAuthEventPayload {
    eventType: MCPOAuthEventType;
    connectionId: string;
    timestamp: string;
    authorizationUrl?: string;
    stateParameter?: string;
    errorMessage?: string;
    requiresReauthorization?: boolean;
}
/**
 * Notification type for OAuth events
 */
export declare class MCPOAuthEventNotification {
    EventType: string;
    ConnectionID: string;
    Timestamp: Date;
    AuthorizationUrl?: string;
    StateParameter?: string;
    ErrorMessage?: string;
    RequiresReauthorization?: boolean;
}
/**
 * MCP Resolver for GraphQL operations
 */
export declare class MCPResolver extends ResolverBase {
    /**
     * Syncs tools from an MCP server connection to the database.
     * Publishes progress updates via the statusUpdates subscription.
     *
     * @param input The sync input parameters
     * @param ctx The GraphQL context
     * @param pubSub PubSub engine for progress updates
     * @returns The sync result
     */
    SyncMCPTools(input: SyncMCPToolsInput, ctx: AppContext, pubSub: PubSubEngine): Promise<SyncMCPToolsResult>;
    /**
     * Executes an MCP tool and returns the result.
     *
     * @param input The execution input parameters
     * @param ctx The GraphQL context
     * @returns The execution result
     */
    ExecuteMCPTool(input: ExecuteMCPToolInput, ctx: AppContext): Promise<ExecuteMCPToolResult>;
    /**
     * Gets OAuth connection status for an MCP connection.
     *
     * @param connectionId - The MCP Server Connection ID
     * @param ctx - GraphQL context
     * @returns OAuth connection status
     */
    GetMCPOAuthConnectionStatus(connectionId: string, ctx: AppContext): Promise<MCPOAuthConnectionStatus>;
    /**
     * Gets OAuth authorization flow status by state parameter.
     *
     * @param input - Input containing state parameter
     * @param ctx - GraphQL context
     * @returns OAuth status result
     */
    GetMCPOAuthStatus(input: GetMCPOAuthStatusInput, ctx: AppContext): Promise<MCPOAuthStatusResult>;
    /**
     * Initiates an OAuth authorization flow for an MCP connection.
     *
     * @param input - Input containing connection ID and optional scopes
     * @param ctx - GraphQL context
     * @returns Initiation result with authorization URL
     */
    InitiateMCPOAuth(input: InitiateMCPOAuthInput, ctx: AppContext): Promise<InitiateMCPOAuthResult>;
    /**
     * Revokes OAuth credentials for an MCP connection.
     *
     * @param input - Input containing connection ID and optional reason
     * @param ctx - GraphQL context
     * @returns Revocation result
     */
    RevokeMCPOAuth(input: RevokeMCPOAuthInput, ctx: AppContext): Promise<RevokeMCPOAuthResult>;
    /**
     * Manually refreshes OAuth tokens for an MCP connection.
     *
     * @param input - Input containing connection ID
     * @param ctx - GraphQL context
     * @returns Refresh result
     */
    RefreshMCPOAuthToken(input: RefreshMCPOAuthTokenInput, ctx: AppContext): Promise<RefreshMCPOAuthTokenResult>;
    /**
     * Subscribes to OAuth events for MCP connections.
     *
     * Clients can subscribe to receive real-time notifications when:
     * - Authorization is required for a connection
     * - Authorization completes successfully
     * - Token is refreshed
     * - Token refresh fails
     *
     * @param payload - The OAuth event payload
     * @returns OAuth event notification
     */
    onMCPOAuthEvent(payload: MCPOAuthEventPayload): MCPOAuthEventNotification;
    /**
     * Loads OAuth configuration for a connection
     */
    private loadConnectionOAuthConfig;
    /**
     * Publishes a progress update to the statusUpdates subscription
     */
    private publishProgress;
    /**
     * Creates an error result with default values
     */
    private createErrorResult;
    /**
     * Creates a result indicating OAuth authorization is required
     */
    private createOAuthRequiredResult;
    /**
     * Creates a result indicating OAuth re-authorization is required
     */
    private createOAuthReauthorizationResult;
    /**
     * Gets the public URL for OAuth callbacks
     */
    private getPublicUrl;
}
/**
 * Publishes an OAuth event to the subscription topic.
 * Can be called from other resolvers or handlers to notify clients of OAuth events.
 *
 * @param pubSub - PubSub engine
 * @param event - OAuth event details
 */
export declare function publishMCPOAuthEvent(pubSub: PubSubEngine, event: {
    eventType: MCPOAuthEventType;
    connectionId: string;
    authorizationUrl?: string;
    stateParameter?: string;
    errorMessage?: string;
    requiresReauthorization?: boolean;
}): Promise<void>;
export {};
//# sourceMappingURL=MCPResolver.d.ts.map