A high-performance analytics and search service for MCP (Model Context Protocol) servers, powering the plugged.in app's discovery and insights features.
The Analytics Service provides:
- 🔍 Advanced Search - Full-text search with filtering, faceting, and sorting
- 📊 Real-time Analytics - Track installs, usage, ratings, and engagement
- 🚀 Discovery Features - Featured servers, trending, top-rated, and personalized recommendations
- 📈 Metrics & Insights - Comprehensive analytics for server performance and user behavior
- ⚡ High Performance - Built with Go, Elasticsearch, and Redis for speed and scale
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ plugged.in App │────▶│ Analytics API │────▶│ Elasticsearch │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
├────────▶ PostgreSQL (User Data)
├────────▶ MongoDB (Analytics)
└────────▶ Redis (Cache)
- Docker and Docker Compose
- Go 1.23+ (for local development)
- 8GB RAM minimum
- 20GB disk space
-
Clone the repository
git clone https://github.com/pluggedin/mcp-analytics.git cd mcp-analytics -
Copy environment configuration
cp .env.example .env # Edit .env with your configuration -
Start all services
make dev
-
Check service health
make health-check
-
View logs
make logs-analytics
- Analytics API: http://localhost:8081
- Kibana: http://localhost:5601
- Adminer (PostgreSQL): http://localhost:8082
- Redis Commander: http://localhost:8083
See PLUGGEDIN_INTEGRATION.md for comprehensive API documentation and integration guide.
GET /v1/search?q=database&package_type=npm&sort=popularityGET /v1/featured
GET /v1/trending?period=week
GET /v1/top-ratedGET /v1/servers/{id}/analytics
POST /v1/installs
POST /v1/ratings
POST /v1/usagemcp-analytics/
├── cmd/analytics/ # Application entry point
├── internal/
│ ├── api/ # HTTP handlers and routing
│ ├── analytics/ # Analytics business logic
│ ├── cache/ # Redis caching layer
│ ├── config/ # Configuration management
│ ├── database/ # Database connections
│ ├── model/ # Data models
│ ├── search/ # Elasticsearch integration
│ └── service/ # Core business services
├── scripts/ # Utility scripts
├── docs/ # Documentation
└── deployments/ # Deployment configurations
# Run tests
make test
# Run with coverage
make test-coverage
# Format code
make fmt
# Run linter
make lint
# Build production image
make build
# Connect to databases
make psql # PostgreSQL CLI
make mongo-shell # MongoDB shell
make redis-cli # Redis CLIMigrations run automatically on startup. To run manually:
make migratemake seedgo test ./...go test -tags=integration ./...make load-testmake prod-builddocker compose -f docker-compose.prod.yml up -dkubectl apply -f deployments/k8s/- Health:
/health- Basic health check - Ready:
/ready- Checks all dependencies
- Prometheus metrics available at
/metrics - Custom business metrics for tracking
- Performance monitoring with OpenTelemetry
- Structured JSON logging with zerolog
- Log aggregation ready
- Configurable log levels
See .env.example for all configuration options. Key settings:
- Database URLs: Configure connections to PostgreSQL, MongoDB, Elasticsearch, Redis
- Cache TTLs: Customize cache durations for different data types
- Rate Limits: Set API rate limits
- Feature Flags: Enable/disable features
- Response caching with Redis
- Database query optimization
- Elasticsearch query tuning
- Connection pooling
- Bulk operations
- Search: <50ms p99 latency
- API endpoints: <100ms p99 latency
- 10k+ requests/second capacity
- Internal API authentication
- Rate limiting per endpoint
- Input validation and sanitization
- SQL injection prevention
- XSS protection
-
Elasticsearch fails to start
- Increase Docker memory limit
- Check
vm.max_map_countsetting
-
Connection refused errors
- Ensure all services are running:
docker compose ps - Check service health:
make health-check
- Ensure all services are running:
-
Slow search performance
- Check Elasticsearch indices:
make elastic-indices - Review query complexity
- Increase cache TTL
- Check Elasticsearch indices:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run
make fmt lint test - Submit a pull request
Copyright © 2024 plugged.in. All rights reserved.
- Documentation: PLUGGEDIN_INTEGRATION.md
- Issues: GitHub Issues
- Email: analytics@plugged.in