Enhanced MCP Server
Production-grade Google services integration (Gmail, Calendar, Drive, Sheets, Keep) with intelligent multi-provider LLM fallback system, featuring automated email categorization, calendar management, and job application tracking.
README
Enhanced MCP Server
<div align="center">
Production-Grade Google Services Integration with Intelligent LLM Fallback
Features • Architecture • Installation • Documentation • Usage
</div>
🎯 Overview
A comprehensive MCP (Model Context Protocol) server that seamlessly integrates Google services (Gmail, Calendar, Drive, Sheets, Keep) with an intelligent multi-provider LLM fallback system. Built for production use with Claude Desktop.
Why This Project?
- 🔄 LLM Reliability: Automatic fallback across 4 LLM providers (Euri → Deepseek → Gemini → Claude)
- ⚡ Production-Grade: Circuit breakers, rate limiting, health checks, comprehensive logging
- 🤖 AI-Powered: Automated email categorization, calendar management, job application tracking
- 📊 Intelligent: Smart summaries, conflict detection, follow-up reminders
- 🔒 Secure: OAuth 2.0, token encryption, environment-based configuration
- 📈 Observable: Structured logging, metrics, cost tracking
✨ Features
🔄 LLM Fallback System (Critical)
The most reliable LLM integration system:
Primary: Euron AI → Fallback 1: Deepseek → Fallback 2: Gemini → Final: Claude
- ✅ Circuit Breaker Pattern: Prevents cascading failures
- ✅ Rate Limiting: Token bucket algorithm (100 calls/min)
- ✅ Health Monitoring: Automatic provider health checks every 5 minutes
- ✅ Cost Tracking: Track spending per provider
- ✅ Retry Logic: Exponential backoff with configurable attempts
- ✅ Provider Caching: Smart routing to last successful provider
📧 Email Intelligence
- Search & Filter: Advanced Gmail queries with AI categorization
- Auto-Categorization: Work, personal, job applications, urgent, spam
- Smart Summaries: Automated summaries every 4 hours (6 AM - 10 PM)
- Calendar Extraction: Automatically detect and extract meeting invites
- Follow-up Reminders: Track emails requiring response
- Thread Management: Group related conversations
- Send & Reply: Draft, send, and reply with AI assistance
📅 Calendar Management
- Event Creation: Full-featured event management with attendees
- Conflict Detection: Automatically detect scheduling conflicts
- Smart Reminders: 15 minutes, 1 hour, 1 day before meetings
- Focus Time: Block calendar for deep work
- Free Slot Finder: Find available time slots
- Daily/Weekly Summaries: Get calendar overview via email
💼 Job Application Tracking
- Auto-Detection: Automatically identify job application emails
- Status Tracking: Applied → Interview → Offer/Rejected
- Company Tracking: Track all companies you've applied to
- Follow-up Reminders: Get reminded to follow up after X days
- Interview Scheduling: Link calendar events to applications
- Analytics: Track application metrics and response rates
- Weekly Reports: Automated summary of applications and responses
📁 Google Drive Integration
- Document Search: Find documents across your entire Drive
- AI Summarization: Get quick summaries of documents
- Format Support: PDF, Docs, Sheets, text files
- Email Attachments: Attach Drive documents to emails
- Smart Caching: Fast repeated access
📊 Google Sheets Integration
- Read/Write/Append: Full spreadsheet operations
- Auto-Create Trackers: Job application tracker, email analytics
- Batch Operations: Efficient bulk updates
- Formula Support: Add formulas programmatically
- Data Export: Export data to sheets for analysis
📝 Google Keep Integration
- Note Management: Create and manage notes
- API Key Storage: Securely store API keys in encrypted notes
- Quick Capture: Fast note-taking from Claude
- Task Lists: Create and manage to-do lists
🔔 Intelligent Notifications
- Meeting Reminders: Never miss a meeting (15m, 1h, 1d before)
- Email Follow-ups: Reminders for pending replies
- Daily Digest: Morning summary of your day
- Weekly Review: Sunday evening roundup
- Custom Schedules: Configure your own notification times
🏗️ Architecture
High-Level Architecture
┌─────────────────────────────────────────────────────────────┐
│ Claude Desktop │
└──────────────────────┬──────────────────────────────────────┘
│ JSON-RPC (stdio)
▼
┌─────────────────────────────────────────────────────────────┐
│ MCP Server │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ 30+ Tools (Email, Calendar, Job, etc.) │ │
│ └──────────────────────────────────────────────────────┘ │
└──────┬────────────────────┬────────────────────┬───────────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
│ Google APIs │ │ LLM Manager │ │ Schedulers │
│ - Gmail │ │ - Euri │ │ - Email │
│ - Calendar │ │ - Deepseek │ │ - Calendar │
│ - Drive │ │ - Gemini │ │ - Notif. │
│ - Sheets │ │ - Claude │ └──────────────┘
│ - Keep │ └──────────────┘
└─────────────┘ │
▼
┌──────────────────┐
│ Circuit Breaker │
│ Rate Limiter │
│ Health Checks │
└──────────────────┘
Technology Stack
- Protocol: MCP (Model Context Protocol) with JSON-RPC 2.0
- Language: Python 3.8+ with async/await
- APIs: Google API Client, OpenAI SDK, Anthropic SDK, Google GenAI
- Orchestration: LangChain + LangGraph for workflows
- Scheduling: APScheduler for automated tasks
- Database: SQLite with SQLAlchemy (async)
- Validation: Pydantic v2 for type safety
- Logging: Structlog (structured JSON logging)
📦 Installation
Prerequisites
- Python 3.8+ (tested with 3.13.5)
- Claude Desktop installed
- Google Cloud Project with APIs enabled:
- Gmail API
- Calendar API
- Drive API
- Sheets API
- API Keys for LLM providers:
- Euron AI API key (primary)
- Deepseek API key (fallback 1)
- Gemini API key (fallback 2)
- Anthropic API key (fallback 3)
Step 1: Clone and Install Dependencies
cd enhanced-mcp-server
pip install -r requirements.txt
Step 2: Google Cloud Setup
- Go to Google Cloud Console
- Create a new project (or select existing)
- Enable APIs:
- Gmail API
- Google Calendar API
- Google Drive API
- Google Sheets API
- Create OAuth 2.0 credentials:
- Application type: Desktop app
- Download
credentials.json
- Place
credentials.jsonin project root
Step 3: Configure Environment
# Copy example environment file
cp .env.example .env
# Edit .env with your API keys
nano .env # or use your favorite editor
Required variables:
# Google
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your-secret
GOOGLE_REDIRECT_URI=http://localhost:8080
# LLM Providers (at least one required)
EURI_API_KEY=your-euri-key
DEEPSEEK_API_KEY=your-deepseek-key
GEMINI_API_KEY=your-gemini-key
ANTHROPIC_API_KEY=your-claude-key
# Application
EMAIL_SUMMARY_RECIPIENT=your-email@gmail.com
Step 4: Run Setup (OAuth Authentication)
python src/setup.py
This will:
- Verify
credentials.jsonexists - Start OAuth flow in your browser
- Save tokens to
tokens.json - Verify authentication success
Step 5: Configure Claude Desktop
Windows: Edit %APPDATA%\Claude\claude_desktop_config.json
Mac: Edit ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: Edit ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"enhanced-google-services": {
"command": "python",
"args": [
"C:\\path\\to\\enhanced-mcp-server\\src\\mcp_server.py"
],
"env": {}
}
}
}
⚠️ Important: Use absolute path to mcp_server.py
Step 6: Restart Claude Desktop
- Completely quit Claude Desktop
- Restart Claude Desktop
- Your tools will be available automatically!
🚀 Usage
Verify Installation
In Claude Desktop, ask:
Show me available tools
You should see 30+ tools listed.
Example Queries
Email Management
"Summarize my unread work emails from the last 24 hours"
"Find all emails about job applications this week"
"Send an email to john@example.com thanking them for the meeting"
"What emails need my follow-up?"
Calendar Management
"Show my calendar for tomorrow"
"Find a 2-hour slot for focus time this week"
"Create a meeting with jane@example.com tomorrow at 2 PM"
"Are there any conflicts in my schedule this week?"
Job Application Tracking
"Show me all job applications I haven't heard back from"
"Add a job application: Applied to Google for SWE role"
"When should I follow up with X company?"
"Give me my job application summary for this week"
Document Search
"Find my resume in Google Drive"
"Summarize the Q4 report document"
"Search for documents about 'machine learning' in my Drive"
📚 Documentation
Complete Documentation Portal
Open docs/index.html in your browser for the full documentation portal.
Key Documents
- Architecture Documentation - System architecture with Mermaid diagrams
- LLM Fallback Flow - Detailed LLM fallback system
- Implementation Guide - Complete code for all remaining files
- Project Structure - Full project organization
Architecture Diagrams
All diagrams are created with Mermaid and include:
- System architecture diagram
- LLM fallback flow
- Circuit breaker state machine
- Rate limiter algorithm
- Component interactions
- Data flow diagrams
- Deployment architecture
- Workflow orchestration
🔧 Configuration
config.yaml
Comprehensive YAML configuration for all features:
email:
categories:
work:
keywords: ["project", "meeting", "deadline"]
job_application:
keywords: ["interview", "application", "recruiter"]
summary:
schedule: "0 6,10,14,18,22 * * *" # Every 4 hours
llm:
providers:
- name: euri
priority: 1
enabled: true
circuit_breaker:
failure_threshold: 5
timeout: 60
rate_limit:
calls_per_minute: 100
See config/config.yaml for full configuration options.
🧪 Testing LLM Fallback
Test the LLM fallback system:
python scripts/test_llm_fallback.py
Expected output:
Testing LLM Fallback System...
✓ Trying Euri... Success! (1.2s)
✓ Response: Hello! How can I help you today?
✓ Cost: $0.0001
✓ Provider health: All healthy
If Euri fails:
✗ Euri failed: Timeout
✓ Trying Deepseek... Success! (0.8s)
✓ Fallback worked correctly!
📊 Monitoring & Health
Health Check Endpoint
# Check system health
curl http://localhost:9090/health
Response:
{
"status": "healthy",
"providers": {
"euri": {"status": "healthy", "success_rate": 0.98},
"deepseek": {"status": "healthy", "success_rate": 0.95},
"gemini": {"status": "healthy", "success_rate": 0.97},
"claude": {"status": "healthy", "success_rate": 0.99}
},
"total_requests": 1523,
"fallback_count": 12,
"total_cost": 2.45
}
Logs
Structured JSON logs in logs/enhanced_mcp.log:
{
"timestamp": "2024-01-15T10:30:45.123Z",
"level": "info",
"event": "llm_request",
"provider": "euri",
"latency": 1.23,
"tokens": 150,
"cost": 0.0001,
"success": true
}
🔐 Security
- OAuth 2.0: Secure Google authentication
- Token Encryption: Encrypted token storage (optional)
- API Key Management: Environment-based secrets
- Rate Limiting: Per-tool rate limits
- Audit Logging: All actions logged
- No Data Storage: Minimal data persistence
🎯 Project Status
✅ Completed (13 core files)
- [x] LLM fallback system (production-grade)
- [x] Circuit breaker pattern
- [x] Rate limiting
- [x] Google OAuth authentication
- [x] Configuration management
- [x] Pydantic models
- [x] Project structure
- [x] Comprehensive documentation with Mermaid diagrams
⏳ To Complete
- [ ] Google API adapters (Gmail, Calendar, Drive, Sheets, Keep)
- [ ] MCP tool definitions (30+ tools)
- [ ] Main MCP server with tool registration
- [ ] LangGraph workflows
- [ ] APScheduler schedulers
- [ ] Database setup and migrations
- [ ] Unit and integration tests
See COMPLETE_IMPLEMENTATION_GUIDE.md for full implementation code.
🤝 Contributing
This is a production-ready template. Feel free to:
- Fork the repository
- Add your own features
- Customize for your use case
- Share improvements
📝 License
MIT License - see LICENSE file for details
🙏 Acknowledgments
- Anthropic - For Claude Desktop and MCP protocol
- Google - For comprehensive API ecosystem
- LangChain - For workflow orchestration
- Community - For feedback and inspiration
📞 Support
- Documentation:
docs/index.html - Implementation Guide:
COMPLETE_IMPLEMENTATION_GUIDE.md - Issues: Use your favorite issue tracker
- Discussions: Share your experiences!
<div align="center">
Built with ❤️ for Production Use
⭐ Star this repo if you find it useful!
</div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.