Skip to main content
Glama

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
NameRequiredDescriptionDefault
interactionYes

Implementation Reference

  • 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'] }
  • 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 }) };
  • 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'] }
  • 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;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/saralegui-solutions/mcp-self-learning-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server