analyze_pattern
Analyzes interaction patterns to learn from usage data, enabling autonomous improvement through pattern recognition and machine learning techniques.
Instructions
Analyze and learn from interaction patterns
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| interaction | Yes |
Implementation Reference
- mcp-self-learning-server.js:953-973 (registration)Registration of the 'analyze_pattern' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.{ name: '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:1157-1169 (handler)The primary handler function for the 'analyze_pattern' tool, which extracts the interaction argument and delegates to the LearningEngine for analysis, then returns structured results including features and recommendations.async 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:956-973 (schema)Input schema definition for the 'analyze_pattern' tool, specifying the structure of the required 'interaction' object.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:76-111 (helper)Core helper function in LearningEngine that performs pattern analysis: creates pattern object, manages memory buffer, extracts features, updates patterns, triggers learning cycles, handles persistence, and emits events.async 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;