An intelligent YouTube Live Chat moderator with MCP (Model Context Protocol) integration, Google AI, and real-time analytics.
- π― Real-time Chat Moderation - Automatically detect and remove toxic content
- π€ AI-Powered Responses - Smart FAQ handling with Google Gemini AI
- π Live Analytics Dashboard - Real-time sentiment analysis and engagement metrics
- π MCP Protocol Integration - 13 advanced tools for external AI agents
- β‘ High-Performance Architecture - Handles 120+ messages/minute with sub-3s response times
- π‘οΈ Multi-layered Safety - Google AI + rule-based moderation systems
- Quick Start
- API Configuration
- MCP Tools
- Architecture
- Configuration Options
- Analytics & Monitoring
- Troubleshooting
- Development
- License
# Clone the repository
git clone https://github.com/yourusername/modbuddy.git
cd modbuddy
# Install Python dependencies
pip install -r requirements.txt
YouTube Data API v3:
- Go to Google Cloud Console
- Enable YouTube Data API v3
- Create OAuth2 credentials
- Download and save as
config/credentials.json.template
(rename tocredentials.json
)
Google AI (Gemini):
- Visit Google AI Studio
- Create API key
- Add to
.env
file
Create .env
file:
YOUTUBE_API_KEY=your_youtube_api_key
YOUTUBE_CLIENT_ID=your_client_id.apps.googleusercontent.com
YOUTUBE_CLIENT_SECRET=your_client_secret
GOOGLE_AI_API_KEY=your_gemini_api_key
YOUTUBE_VIDEO_ID=your_live_video_id
TOXICITY_THRESHOLD=0.7
MCP_SERVER_PORT=7860
Web Dashboard:
python run.py
Access at: http://localhost:7860
MCP Server (for Claude Desktop):
python mcp_fast_server.py
Purpose: Read/write YouTube Live Chat messages
Cost: Free tier (10,000 units/day β 2,000 operations)
Setup:
- Enable API in Google Cloud Console
- Create OAuth2 credentials (not API key)
- Configure authorized redirect URIs
- Download client configuration JSON
Required OAuth2 credentials format (config/credentials.json
):
{
"installed": {
"client_id": "your-client-id.apps.googleusercontent.com",
"client_secret": "your-oauth2-client-secret",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}
Purpose: Intelligent question answering and content analysis
Cost: Free tier (60 requests/minute)
Setup: Simple API key from Google AI Studio
ModBuddy exposes 5 standardized MCP tools for integration with AI agents:
Fetch live chat messages with filtering options.
{
"since_iso": "2024-01-15T10:30:00Z",
"max_results": 50
}
Send messages to the live chat as the bot.
{
"text": "Welcome to the stream!"
}
Remove toxic or inappropriate messages.
{
"message_id": "abc123xyz"
}
Analyze message toxicity and get moderation recommendations.
{
"text": "Message content to analyze"
}
Retrieve real-time analytics and engagement metrics.
{
"window_minutes": 10
}
Access MCP tools at: http://localhost:7860/tools/list
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββββ
β AI Agents ββββββ MCP Protocol ββββββ ModBuddy β
β (Claude/GPT) β β (5 tools) β β Main Server β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ModBuddy Core β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββ€
β YouTube Client β Google AI β Database β Web Dashboard β
β (OAuth2 + API) β (Gemini) β (SQLite) β (Gradio) β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββ
β YouTube Live Chat β
β (Real-time messages) β
βββββββββββββββββββββββββββββββββββ
Variable | Description | Default | Required |
---|---|---|---|
YOUTUBE_API_KEY |
YouTube Data API v3 key | - | β |
YOUTUBE_CLIENT_ID |
OAuth2 client ID | - | β |
YOUTUBE_CLIENT_SECRET |
OAuth2 client secret | - | β |
GOOGLE_AI_API_KEY |
Gemini AI API key | - | β |
YOUTUBE_VIDEO_ID |
Live stream video ID | - | β |
TOXICITY_THRESHOLD |
Moderation sensitivity (0.1-1.0) | 0.7 | β |
CHAT_POLL_INTERVAL |
Message fetch interval (seconds) | 5 | β |
MCP_SERVER_PORT |
Server port | 7860 | β |
- Toxicity Threshold: 0.1 (very strict) to 1.0 (very permissive)
- Auto-moderation: Automatically delete toxic messages
- Auto-response: AI-generated responses to frequently asked questions
- Custom Rules: Extend simple moderation with custom keywords
- π Message Velocity - Messages per minute trending
- π Sentiment Analysis - Positive/Neutral/Negative breakdown
- π₯ User Activity - Most active participants
- π¨ Toxicity Timeline - Content safety over time
- π Language Detection - Multi-language chat support
Optimal Configuration:
- Processes ~120 messages/minute
- <3 second response time for AI answers
- <2 second moderation decisions
- Supports ~2,000 daily operations (YouTube quota)
# Clear cached tokens and re-authenticate
rm config/token.json
python run.py
Common fixes:
- Verify OAuth2 credentials in
config/credentials.json
- Check YouTube Data API v3 is enabled
- Ensure video is currently live with chat enabled
- Verify API key at Google AI Studio
- Check rate limits (60 requests/minute on free tier)
- Monitor quota usage in API dashboard
# Test MCP endpoints directly
curl http://localhost:7860/tools/list
# Expected: JSON response with 5 tool definitions
High-traffic streams:
- Increase
CHAT_POLL_INTERVAL
to reduce API calls - Lower
TOXICITY_THRESHOLD
for stricter moderation - Enable Redis caching for repeated questions
modbuddy/
βββ src/
β βββ main.py # Gradio web server & MCP endpoints
β βββ mcp_tools.py # MCP tool implementations
β βββ youtube_client.py # YouTube Data API v3 wrapper
β βββ google_ai.py # Gemini AI integration
β βββ simple_moderation.py # Rule-based content filtering
β βββ database.py # SQLite data persistence
βββ config/
β βββ credentials.json.template # OAuth2 template
βββ requirements.txt # Python dependencies
βββ run.py # Application launcher
βββ README.md # This file
# Test API connections
python -c "from src.youtube_client import YouTubeClient; YouTubeClient().test_connection()"
# Test Gemini AI
python -c "from src.google_ai import GoogleAIClient; GoogleAIClient().test_connection()"
- Fork the repository
- Create a 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 a Pull Request
- Auto-moderate toxic gaming chat
- Handle stream commands and FAQs
- Real-time sentiment monitoring during gameplay
- Manage Q&A sessions automatically
- Filter inappropriate content in learning environments
- Track student engagement metrics
- Remove spam during live demos
- Gauge audience sentiment
- Answer product questions intelligently
- Integrate via MCP for custom automation
- Build chat analytics pipelines
- Create moderation workflows
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Model Context Protocol (MCP) for standardized AI tool integration
- Google AI for Gemini API and natural language processing
- YouTube Data API v3 for live chat access
- Gradio for rapid web interface development
Ready to moderate smarter? π
β‘ Quick Start: pip install -r requirements.txt && python run.py
π§ Configure APIs: Follow API Configuration
π View Dashboard: http://localhost:7860
π MCP Tools: http://localhost:7860/tools/list