MCP Self-Learning Server

MCP Self-Learning Server

Enables autonomous learning from interactions through pattern recognition and machine learning techniques. Continuously improves performance by analyzing tool usage, providing predictive suggestions, and sharing knowledge across MCP servers.

Category
访问服务器

README

MCP Self-Learning Server

A sophisticated Model Context Protocol (MCP) server that autonomously learns from interactions, optimizes performance, and continuously improves its knowledge base through pattern recognition and machine learning techniques.

🌟 Features

🧠 Autonomous Learning Engine

  • Pattern Recognition: Automatically identifies and learns from interaction patterns
  • Feature Extraction: Analyzes tool sequences, context, performance metrics, and semantic embeddings
  • Confidence Scoring: Evaluates pattern reliability based on frequency, recency, and consistency
  • Memory Consolidation: Manages short-term and long-term pattern storage

🔄 Knowledge Synchronization

  • Auto-sync: Every 60 seconds between MCP servers
  • Knowledge Export/Import: JSON and Markdown formats
  • Pattern Merging: With deduplication
  • Cross-server Learning: Through shared knowledge directory

📊 Self-Improvement Capabilities

  • Performance Optimization: Identifies redundancies and bottlenecks
  • Predictive Suggestions: Anticipates next actions based on learned patterns
  • Error Pattern Analysis: Learns from failures to improve success rates
  • Adaptive Recommendations: Generates context-aware optimizations

💾 Data Persistence

  • Automatic Data Saving: Every 5 minutes with backup rotation
  • Learning Data Recovery: Loads previous sessions on startup
  • Export Knowledge: Multiple formats (JSON, Markdown)
  • Backup System: Automatic backup creation before saves

📝 Advanced Logging

  • Multi-level Logging: Debug, Info, Warn, Error with colors and emojis
  • File & Console Output: Simultaneous logging to both
  • Log Rotation: Prevents disk space issues
  • Performance Monitoring: Tool execution times and memory usage

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

  1. Clone/Download the Project

    cd ~/saralegui-solutions-llc/shared/MCPSelfLearningServer
    
  2. Install Dependencies

    npm install
    
  3. Configure Claude Desktop

    Add to ~/.config/Claude/claude_desktop_config.json:

    {
      "mcpServers": {
        "self-learning": {
          "command": "node",
          "args": ["/home/ben/saralegui-solutions-llc/shared/MCPSelfLearningServer/mcp-self-learning-server.js"],
          "env": {
            "NODE_ENV": "production",
            "LEARNING_MODE": "autonomous"
          }
        }
      }
    }
    
  4. Start the Server

    npm start
    

📋 Available Commands

Development & Testing

npm run dev          # Start in development mode
npm run debug        # Start with debug logging
npm test             # Run all tests
npm run test:unit    # Run unit tests only
npm run test:integration  # Run integration tests only

Monitoring & Health

npm run health       # Run comprehensive health check
npm run monitor      # Real-time monitoring
npm run monitor:details  # Detailed monitoring with change tracking

Manual Operations

# Health check
node tools/health-check.js

# Real-time monitoring
node tools/monitor.js [--interval 5] [--details]

# Start server directly
node mcp-self-learning-server.js

🛠️ Available MCP Tools

Core Learning Tools

analyze_pattern

Analyze and learn from interaction patterns

{
  "interaction": {
    "type": "tool_usage",
    "input": "user input",
    "output": "tool output", 
    "context": {},
    "performance": { "duration": 100 },
    "success": true
  }
}

get_insights

Get current learning analytics and insights

{}

trigger_learning

Manually trigger a learning cycle

{}

Knowledge Management

export_knowledge

Export learned knowledge to file

{
  "format": "json|markdown"  // Optional, defaults to json
}

import_knowledge

Import knowledge from external source

{
  "source": "file_path_or_url",
  "format": "json"  // Optional
}

Performance & Optimization

optimize_tool

Get optimization suggestions for specific tools

{
  "tool_name": "example_tool"  // Optional
}

predict_next_action

Get predictive suggestions based on current context

{
  "context": {
    "current_tool": "analyze_pattern",
    "user_intent": "optimization"
  }
}

get_performance_metrics

Get detailed performance analytics

{
  "tool_name": "specific_tool"  // Optional, for tool-specific metrics
}

📊 Monitoring & Analytics

Health Check Results

The health check tool verifies:

  • ✅ Server startup functionality
  • ✅ Data persistence system
  • ✅ Logging system
  • ✅ Performance metrics (startup time)

Real-time Monitoring

The monitor displays:

  • Learning engine status (patterns, knowledge, cycles)
  • Log file metrics and activity
  • System resource usage
  • Change indicators showing growth over time

Performance Expectations

Metric Target Excellent
Startup Time <5s <1s
Memory Usage <100MB <50MB
Response Time <500ms <100ms
Learning Accuracy >70% >90%

🗂️ Directory Structure

MCPSelfLearningServer/
├── mcp-self-learning-server.js    # Main server file
├── package.json                   # Dependencies and scripts
├── README.md                      # This file
├── data/                         # Persistent learning data
│   ├── learning-engine.json      # Main learning data
│   └── learning-engine.backup.json # Backup
├── logs/                         # Server logs
│   └── mcp-server.log           # Main log file
├── lib/                         # Shared libraries
│   └── logger.js               # Enhanced logging system
├── test/                       # Test suites
│   ├── unit/                  # Unit tests
│   └── integration/          # Integration tests
└── tools/                    # Development tools
    ├── health-check.js      # Health check tool
    └── monitor.js          # Real-time monitoring

🔧 Configuration

Environment Variables

Variable Default Description
NODE_ENV production Environment mode
LOG_LEVEL info Logging level (debug/info/warn/error)
LOG_CONSOLE true Enable console logging
LOG_FILE true Enable file logging
LEARNING_MODE autonomous Learning behavior mode

Learning Engine Settings

  • Max Memory Size: 1000 patterns in memory
  • Auto-save Interval: 5 minutes
  • Pattern Confidence Threshold: 0.5
  • Learning Trigger: Every 100 interactions or 50 tool uses

🚨 Troubleshooting

Common Issues

  1. Server Won't Start

    • Check Node.js version (18+ required)
    • Verify all dependencies installed: npm install
    • Check file permissions
  2. Data Not Persisting

    • Verify data/ directory permissions
    • Check disk space
    • Review logs for errors: tail -f logs/mcp-server.log
  3. High Memory Usage

    • Run health check: npm run health
    • Check pattern count: npm run monitor
    • Consider reducing max memory size
  4. Slow Performance

    • Enable performance logging: npm run debug
    • Check system resources
    • Review learning cycle frequency

Log Analysis

# View recent logs
tail -f logs/mcp-server.log

# Search for errors
grep "ERROR" logs/mcp-server.log

# Count log levels
grep -c "INFO\|WARN\|ERROR" logs/mcp-server.log

📈 Expected Learning Outcomes

Immediate (0-100 interactions)

  • Basic pattern recognition active
  • Initial knowledge base building
  • Tool usage tracking enabled

Short-term (100-1000 interactions)

  • Pattern confidence scores stabilizing
  • First optimization recommendations
  • Predictive accuracy ~50%

Long-term (1000+ interactions)

  • Predictive accuracy >70%
  • Response time improvements ~30%
  • Comprehensive knowledge graph
  • Cross-server knowledge sharing
  • Self-documenting insights

🤝 Integration with Claude

Once configured, the server provides these tools in Claude:

  • Pattern analysis for learning from conversations
  • Performance insights for optimization
  • Predictive suggestions for improved responses
  • Knowledge export for documentation
  • Real-time learning from every interaction

📝 License

ISC License

🆘 Support

For issues or questions:

  1. Run health check: npm run health
  2. Check logs: tail -f logs/mcp-server.log
  3. Review this documentation
  4. Check server status: npm run monitor

Built with ❤️ for autonomous learning and continuous improvement

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选