import OpenAI from 'openai'; import { ConversationMessage, MemoryConfig } from '../memory-manager.js'; export interface MCPClientRequest { query: string; sessionId?: string; userId?: string; model?: string; temperature?: number; max_tokens?: number; includeContext?: boolean; updatePreferences?: boolean; useMemory?: boolean; maxIterations?: number; enableDebugLogging?: boolean; } export interface MCPClientResponse { response: string; tools_used: string[]; data_sources: string[]; timestamp: string; sessionId?: string; context_used?: boolean; user_preferences_updated?: boolean; conversation_length?: number; context_summarized?: boolean; context_summary?: any; token_count?: any; iterations_used?: number; iteration_details?: { iteration: number; tools_called: string[]; purpose: string; tool_parameters?: { tool_name: string; parameters: any; }[]; }[]; } export interface MCPClientConfig { memoryConfig?: Partial; openaiApiKey?: string; enableMemory?: boolean; enableContextSummarization?: boolean; enableDebugLogging?: boolean; } /** * Unified MCP Client with OpenAI Function Calling, Memory, and Context Summarization * * This is the single, unified MCP client that combines all features: * - OpenAI function calling for natural language queries * - Memory management for context awareness * - Context summarization for handling long conversations * - Session management for multi-user support */ export declare class MCPClient { private nseClient; private openai; private availableTools; private memoryManager?; private config; private currentQuery?; private allToolsUsed; constructor(config?: MCPClientConfig); /** * Debug logging method */ private debugLog; /** * Enable or disable debug logging on this client instance */ setDebugLogging(enabled: boolean): void; /** * Get current debug logging status */ isDebugLoggingEnabled(): boolean; /** * Convert MCP tools to OpenAI function format */ private convertToolsToOpenAIFunctions; /** * Extract stock symbols from query for context tracking */ private extractStockSymbols; /** * Get base system prompt without context */ private getBaseSystemPrompt; /** * Process a natural language query with multi-iteration support (default: 5 iterations) */ processQuery(request: MCPClientRequest): Promise; /** * Execute function calls using the NSE India API */ private executeFunctionCall; /** * Determine if iterations should continue based on AI response and context */ private shouldContinueIterating; /** * Infer the purpose of an iteration based on tools called */ private inferIterationPurpose; /** * Build the final response with all tracking information */ private buildFinalResponse; /** * Update user preferences based on query patterns */ private updateUserPreferencesFromQuery; /** * Get session information */ getSessionInfo(sessionId: string): any; /** * Update user preferences manually */ updateUserPreferences(sessionId: string, preferences: Record): void; /** * Get conversation history */ getConversationHistory(sessionId: string, maxMessages?: number): ConversationMessage[]; /** * Get conversation history with context summarization */ getConversationHistoryWithSummarization(sessionId: string, maxMessages?: number, systemPrompt?: string): Promise<{ messages: ConversationMessage[]; summary?: any; wasSummarized: boolean; tokenCount: any; }>; /** * Clear session data */ clearSession(sessionId: string): void; /** * Export session data */ exportSessionData(sessionId: string): any; /** * Check if context needs summarization */ needsContextSummarization(sessionId: string, systemPrompt?: string): Promise; /** * Get context statistics */ getContextStats(sessionId: string, systemPrompt?: string): Promise<{ messageCount: number; tokenCount: any; needsSummarization: boolean; contextWindowUsage: number; }>; /** * Force context summarization */ forceContextSummarization(sessionId: string, systemPrompt?: string): Promise; /** * Update context window configuration */ updateContextWindowConfig(config: Record): void; /** * Get context window configuration */ getContextWindowConfig(): any; /** * Cleanup expired sessions */ cleanupExpiredSessions(): void; /** * Get available tools information */ getAvailableTools(): any[]; /** * Get tools in OpenAI function format */ getOpenAIFunctions(): OpenAI.Chat.Completions.ChatCompletionCreateParams.Function[]; /** * Test the MCP client connection */ testConnection(): Promise; /** * Test the MCP client with memory */ testConnectionWithMemory(sessionId: string): Promise; /** * Get client configuration */ getConfig(): MCPClientConfig; /** * Check if memory is enabled */ isMemoryEnabled(): boolean; /** * Check if context summarization is enabled */ isContextSummarizationEnabled(): boolean; /** * Get last summarization for a session */ getLastSummarization(sessionId: string): any; /** * Get summarization history for a session */ getSummarizationHistory(sessionId: string, limit?: number): any[]; /** * Get summarization summary for a session */ getSummarizationSummary(sessionId: string): any; /** * Get OpenAI messages for a session (including system message) */ getOpenAIMessages(sessionId: string): any; } export declare const mcpClient: MCPClient; export declare function createMCPClient(config: MCPClientConfig): MCPClient; //# sourceMappingURL=mcp-client.d.ts.map