UNPKG

@spaik/mcp-server-roi

Version:

MCP server for AI ROI prediction and tracking with Monte Carlo simulations

481 lines 16 kB
import { z } from 'zod'; /** * Cross-Tool Memory Service * * Preserves context across tool invocations, learns from interactions, * and provides intelligent context for subsequent queries. */ export declare const QueryContextSchema: z.ZodObject<{ id: z.ZodString; timestamp: z.ZodString; tool: z.ZodString; input: z.ZodAny; output: z.ZodAny; insights: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; metadata: z.ZodOptional<z.ZodObject<{ execution_time_ms: z.ZodNumber; confidence_score: z.ZodOptional<z.ZodNumber>; data_quality: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; }, { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }, { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }>; export declare const ConversationThreadSchema: z.ZodObject<{ thread_id: z.ZodString; created_at: z.ZodString; last_active: z.ZodString; queries: z.ZodArray<z.ZodObject<{ id: z.ZodString; timestamp: z.ZodString; tool: z.ZodString; input: z.ZodAny; output: z.ZodAny; insights: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; metadata: z.ZodOptional<z.ZodObject<{ execution_time_ms: z.ZodNumber; confidence_score: z.ZodOptional<z.ZodNumber>; data_quality: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; }, { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }, { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }>, "many">; context: z.ZodObject<{ domain: z.ZodOptional<z.ZodString>; organization_id: z.ZodOptional<z.ZodString>; project_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; key_metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; learned_preferences: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, "strip", z.ZodTypeAny, { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }, { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }>; summary: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { created_at: string; context: { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }; thread_id: string; last_active: string; queries: { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }[]; summary?: string | undefined; }, { created_at: string; context: { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }; thread_id: string; last_active: string; queries: { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }[]; summary?: string | undefined; }>; export declare const MemoryStoreSchema: z.ZodObject<{ threads: z.ZodMap<z.ZodString, z.ZodObject<{ thread_id: z.ZodString; created_at: z.ZodString; last_active: z.ZodString; queries: z.ZodArray<z.ZodObject<{ id: z.ZodString; timestamp: z.ZodString; tool: z.ZodString; input: z.ZodAny; output: z.ZodAny; insights: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; metadata: z.ZodOptional<z.ZodObject<{ execution_time_ms: z.ZodNumber; confidence_score: z.ZodOptional<z.ZodNumber>; data_quality: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; }, { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }, { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }>, "many">; context: z.ZodObject<{ domain: z.ZodOptional<z.ZodString>; organization_id: z.ZodOptional<z.ZodString>; project_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; key_metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; learned_preferences: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, "strip", z.ZodTypeAny, { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }, { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }>; summary: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { created_at: string; context: { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }; thread_id: string; last_active: string; queries: { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }[]; summary?: string | undefined; }, { created_at: string; context: { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }; thread_id: string; last_active: string; queries: { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }[]; summary?: string | undefined; }>>; global_insights: z.ZodArray<z.ZodObject<{ insight: z.ZodString; confidence: z.ZodNumber; source_queries: z.ZodArray<z.ZodString, "many">; timestamp: z.ZodString; }, "strip", z.ZodTypeAny, { confidence: number; timestamp: string; insight: string; source_queries: string[]; }, { confidence: number; timestamp: string; insight: string; source_queries: string[]; }>, "many">; domain_knowledge: z.ZodRecord<z.ZodString, z.ZodObject<{ facts: z.ZodArray<z.ZodString, "many">; patterns: z.ZodArray<z.ZodString, "many">; benchmarks: z.ZodRecord<z.ZodString, z.ZodAny>; }, "strip", z.ZodTypeAny, { patterns: string[]; facts: string[]; benchmarks: Record<string, any>; }, { patterns: string[]; facts: string[]; benchmarks: Record<string, any>; }>>; }, "strip", z.ZodTypeAny, { threads: Map<string, { created_at: string; context: { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }; thread_id: string; last_active: string; queries: { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }[]; summary?: string | undefined; }>; global_insights: { confidence: number; timestamp: string; insight: string; source_queries: string[]; }[]; domain_knowledge: Record<string, { patterns: string[]; facts: string[]; benchmarks: Record<string, any>; }>; }, { threads: Map<string, { created_at: string; context: { organization_id?: string | undefined; project_ids?: string[] | undefined; domain?: string | undefined; key_metrics?: Record<string, any> | undefined; learned_preferences?: Record<string, any> | undefined; }; thread_id: string; last_active: string; queries: { id: string; tool: string; timestamp: string; insights?: string[] | undefined; metadata?: { execution_time_ms: number; confidence_score?: number | undefined; data_quality?: string | undefined; } | undefined; input?: any; output?: any; }[]; summary?: string | undefined; }>; global_insights: { confidence: number; timestamp: string; insight: string; source_queries: string[]; }[]; domain_knowledge: Record<string, { patterns: string[]; facts: string[]; benchmarks: Record<string, any>; }>; }>; export type QueryContext = z.infer<typeof QueryContextSchema>; export type ConversationThread = z.infer<typeof ConversationThreadSchema>; export type MemoryStore = z.infer<typeof MemoryStoreSchema>; export declare class CrossToolMemory { private logger; private memoryStore; private activeThreadId; private readonly CONFIG; constructor(); /** * Start or continue a conversation thread */ startThread(threadId?: string): Promise<string>; /** * Record a query and its results */ recordQuery(tool: string, input: any, output: any, metadata?: QueryContext['metadata']): Promise<void>; /** * Get relevant context for a new query */ getRelevantContext(tool: string, input: any): Promise<{ previous_results: any[]; related_insights: string[]; domain_facts: string[]; suggestions: string[]; }>; /** * Get cross-tool insights */ getCrossToolInsights(): Promise<{ patterns: Array<{ pattern: string; tools_involved: string[]; frequency: number; confidence: number; }>; recommendations: string[]; optimization_opportunities: string[]; }>; /** * Summarize conversation thread */ summarizeThread(threadId?: string): Promise<{ summary: string; key_findings: string[]; decisions_made: string[]; next_steps: string[]; }>; /** * Export memory for persistence */ exportMemory(): Promise<string>; /** * Import memory from persistence */ importMemory(data: string): Promise<void>; private generateThreadId; private generateQueryId; private extractInsights; private updateThreadContext; private learnFromQuery; private extractKeyOutputs; private findRelatedInsights; private inferDomain; private generateSuggestions; private detectQueryPatterns; private generateCrossToolRecommendations; private identifyOptimizations; private getEmptySummary; private generateThreadSummary; private extractKeyFindings; private extractDecisions; private suggestNextSteps; private updateAverage; private detectConsecutiveTools; private findSimilarQueries; private calculateInputSimilarity; private getToolUsageStats; private getThreadDuration; } export declare const crossToolMemory: CrossToolMemory; //# sourceMappingURL=cross-tool-memory.d.ts.map