analyze_pattern
Identify and learn from interaction patterns to enhance system performance. Provide predictive insights and improve tool usage efficiency by analyzing data inputs and outcomes.
Instructions
Analyze and learn from interaction patterns
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| interaction | Yes |
Implementation Reference
- mcp-self-learning-server.js:76-111 (handler)Core handler in LearningEngine that performs pattern analysis, feature extraction, pattern updating, learning cycle triggering, and persistence for the analyze_pattern tool logicasync analyzePattern(interaction) { const pattern = { id: crypto.randomUUID(), timestamp: new Date().toISOString(), type: interaction.type, input: interaction.input, output: interaction.output, context: interaction.context, performance: interaction.performance, success: interaction.success }; // Store in memory buffer this.memoryBuffer.push(pattern); if (this.memoryBuffer.length > this.maxMemorySize) { await this.consolidateMemory(); } // Extract features const features = this.extractFeatures(pattern); // Update pattern recognition await this.updatePatterns(features); // Trigger learning if threshold met if (this.shouldTriggerLearning()) { await this.performLearningCycle(); } // Auto-save if interval elapsed if (this.shouldAutoSave()) { await this.saveToFile(); } this.emit('pattern-analyzed', pattern); return pattern;
- mcp-self-learning-server.js:1157-1169 (handler)MCP server tool handler for 'analyze_pattern' that extracts interaction, calls LearningEngine.analyzePattern, and returns results with features and recommendationsasync handleAnalyzePattern(args) { const { interaction } = args; const pattern = await this.learningEngine.analyzePattern(interaction); return { success: true, patternId: pattern.id, features: this.learningEngine.extractFeatures(pattern), recommendations: this.learningEngine.generateRecommendations({ features: this.learningEngine.extractFeatures(pattern), confidence: 0.5 }) };
- mcp-self-learning-server.js:1069-1071 (registration)Registration/dispatch in CallToolRequestSchema handler that routes 'analyze_pattern' calls to handleAnalyzePatternswitch (name) { case 'analyze_pattern': result = await this.handleAnalyzePattern(args);
- mcp-self-learning-server.js:954-973 (registration)Tool registration in ListToolsRequestSchema including name, description, and input schemaname: 'analyze_pattern', description: 'Analyze and learn from interaction patterns', inputSchema: { type: 'object', properties: { interaction: { type: 'object', properties: { type: { type: 'string' }, input: { type: 'string' }, output: { type: 'string' }, context: { type: 'object' }, performance: { type: 'object' }, success: { type: 'boolean' } }, required: ['type', 'input', 'output'] } }, required: ['interaction'] }
- mcp-self-learning-server.js:117-125 (helper)Key helper method called by analyzePattern to extract features like tool sequence, context, performance, embedding, and temporal patternsextractFeatures(pattern) { return { toolSequence: this.identifyToolSequence(pattern), contextualCues: this.extractContextualCues(pattern), performanceMetrics: this.calculatePerformanceMetrics(pattern), semanticEmbedding: this.generateSemanticEmbedding(pattern), temporalPatterns: this.identifyTemporalPatterns(pattern) }; }