A sophisticated AI-powered betting advisor featuring a multi-agent architecture built with CrewAI. Four specialized AI agents collaborate to analyze games, evaluate props, and construct optimal parlay combinations.
This system uses CrewAI to orchestrate multiple specialized agents that work together to provide intelligent, high-confidence parlay recommendations. The agents analyze player availability, run ML predictions, optimize parlay combinations, and validate recommendations for quality and accuracy.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ USER REQUEST โ
โ "Build 8-leg 100x parlay for Bengals vs Packers" โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Crew Orchestrator โ
โ - Request Analysis โ
โ - Agent Routing โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Roster Agent โ โ Stats Agent โ โ Parlay Optimizerโ
โ โข Injuries โ โ โข ML Models โ โ โข Combinations โ
โ โข Availabilityโ โ โข Props โ โ โข Correlations โ
โ โข Weather โ โ โข Matchups โ โ โข Optimization โ
โโโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโ
โ QA Agent โ
โ โข Validate โ
โ โข Correlate โ
โ โข Approve โ
โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ 2-3 Parlay Options โ
โ โข 8 legs โ
โ โข ~100x multiplier โ
โ โข Confidence scores โ
โ โข Full reasoning โ
โโโโโโโโโโโโโโโโโโโโโโโโ
-
Roster Intelligence Agent
- Monitors player injury status and availability
- Analyzes weather conditions and game factors
- Checks depth charts and playing time projections
- Validates all players are healthy and active
-
Stats & Props Agent
- Runs ML predictions for player performance
- Analyzes historical stats and matchups
- Calculates prop hit probabilities
- Identifies 20-30 high-confidence opportunities
-
Quality Assurance Agent
- Validates all recommendations for accuracy
- Checks for contradictory or correlated props
- Assesses overall correlation risk
- Provides final approval or rejection
-
Parlay Optimizer Agent
- Constructs optimal parlay combinations
- Balances confidence with target multipliers
- Manages correlation risk across legs
- Generates multiple parlay options
Roster Tools:
- Player injury status checking
- Team roster analysis
- Player availability verification
- Weather condition forecasting
Stats Tools:
- Historical stats analysis
- ML-based predictions
- Matchup analysis
- Prop probability calculations
Betting Tools:
- Parlay odds calculation
- Leg optimization algorithms
- Expected value calculation
- Correlation risk assessment
Data Tools:
- Player search and filtering
- Game schedule retrieval
- Prop market analysis
# Clone repository
git clone https://github.com/mattarm/fantasy_mcp.git
cd fantasy_mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Copy environment template
cp env.example .env
# Edit .env and add your OpenAI API key
OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-4
# Other optional configurations
AGENT_VERBOSE=true
PARLAY_MIN_CONFIDENCE=0.65
PARLAY_MAX_LEGS=15# Run validation tests
python test_agent_system.py# Start MCP server
python -m fantasy_mcp.mainRequest:
"Put together high confidence 8 leg parlay with a 100x return for this weeks Bengals Packers game"
Process:
- Roster Agent identifies the game and checks all players
- Stats Agent analyzes props and runs ML predictions
- Parlay Optimizer finds 8-leg combinations hitting ~100x
- QA Agent validates and provides final recommendations
Output:
- 2-3 complete parlay options
- Each with 8 legs, ~100x multiplier
- Confidence scores for each leg
- Correlation risk analysis
- Detailed reasoning
Request:
"Put together a 800x parlay for this Sunday's noon games"
Process:
- Identifies all Sunday noon games (4-6 games)
- Analyzes 60-100+ props across all games
- Finds 10-12 leg combinations hitting ~800x
- Diversifies across games to reduce correlation
- Validates and provides recommendations
# Use build_optimized_parlay tool
result = await mcp_client.call_tool("build_optimized_parlay", {
"request": "Build 8-leg 100x parlay for Bengals vs Packers game"
})
# Get parlay history
history = await mcp_client.call_tool("get_parlay_history", {
"limit": 10
})
# Retrieve specific parlay
parlay = await mcp_client.call_tool("get_parlay_by_id", {
"parlay_id": "abc123..."
})fantasy_mcp/
โโโ src/fantasy_mcp/
โ โโโ agents/ # AI agents
โ โ โโโ roster_intelligence_agent.py
โ โ โโโ stats_props_agent.py
โ โ โโโ qa_agent.py
โ โ โโโ parlay_optimizer_agent.py
โ โโโ crews/ # Crew orchestration
โ โ โโโ betting_crew.py
โ โ โโโ crew_orchestrator.py
โ โโโ tools/ # Agent tools
โ โ โโโ roster_tools.py
โ โ โโโ stats_tools.py
โ โ โโโ betting_tools.py
โ โ โโโ data_tools.py
โ โโโ data_store/ # Data management
โ โ โโโ file_manager.py
โ โ โโโ cache_manager.py
โ โโโ services/ # Core services
โ โ โโโ sleeper_api.py
โ โ โโโ ml_predictor.py
โ โ โโโ betting_advisor.py
โ โโโ api/ # MCP server
โ โ โโโ mcp_server.py
โ โโโ core/ # Core utilities
โ โโโ config.py
โ โโโ database.py
โโโ data/ # File-based storage
โ โโโ players/
โ โโโ stats/
โ โโโ predictions/
โ โโโ bets/parlays/
โ โโโ cache/
โโโ tests/ # Test suite
โโโ archive/ # Archived old scripts
โโโ test_agent_system.py # System tests
โโโ AGENT_SYSTEM_README.md # Detailed agent docs
โโโ IMPLEMENTATION_SUMMARY.md # Implementation details
โโโ requirements.txt # Dependencies
-
Request Analysis (Orchestrator)
- Parse user request
- Extract: target multiplier, number of legs, games, time slots
- Route to appropriate workflow
-
Player Availability (Roster Agent)
- Check all relevant players
- Verify injury status
- Assess weather conditions
- Return availability report
-
Prop Analysis (Stats Agent)
- Analyze available props
- Run ML predictions
- Calculate hit probabilities
- Return ranked high-confidence props
-
Parlay Construction (Optimizer Agent)
- Build leg combinations
- Optimize for target multiplier
- Manage correlation risk
- Generate multiple options
-
Quality Validation (QA Agent)
- Validate player status
- Check for contradictions
- Assess correlations
- Approve or reject
-
Final Output
- 2-3 complete parlay recommendations
- Confidence scores and reasoning
- Risk assessment
- Saved to data/bets/parlays/
# AI/LLM (Required)
OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-4
# Agent Configuration
AGENT_VERBOSE=true
AGENT_MAX_ITERATIONS=15
AGENT_MAX_EXECUTION_TIME=300
# Parlay Settings
PARLAY_MIN_CONFIDENCE=0.65
PARLAY_MAX_LEGS=15
PARLAY_CORRELATION_THRESHOLD=0.3
# Betting Configuration
DEFAULT_BANKROLL=1000.0
KELLY_FRACTION=0.25- Confidence Threshold: Minimum confidence for props (default: 0.65)
- Max Legs: Maximum parlay legs (default: 15)
- Correlation Threshold: Maximum acceptable correlation (default: 0.3)
- Kelly Fraction: Bet sizing aggressiveness (default: 0.25)
File-based storage (migration-ready for database):
data/
โโโ players/
โ โโโ {player_id}.json # Player info
โโโ stats/
โ โโโ {player_id}/
โ โโโ {season}_week_{week}.json
โโโ predictions/
โ โโโ {date}/
โ โโโ {player_id}.json # ML predictions
โโโ bets/
โ โโโ parlays/
โ โ โโโ {parlay_id}.json # Saved parlays
โ โโโ history/
โโโ cache/
โโโ {cache_key}.json # API cache
# Run system tests
python test_agent_system.py
# With full agent execution (requires API key)
OPENAI_API_KEY=your_key python test_agent_system.py
# Run pytest suite
pytest tests/
# Run with coverage
pytest --cov=src/fantasy_mcp- AGENT_SYSTEM_README.md - Complete agent system documentation
- IMPLEMENTATION_SUMMARY.md - Detailed implementation overview
- test_agent_system.py - Usage examples and tests
- archive/README.md - Information about archived files
The system provides three main MCP tools:
Build an AI-optimized parlay with specified parameters.
{
"request": "Natural language parlay request"
}View recent parlay recommendations.
{
"limit": 10 # Number of parlays to retrieve
}Retrieve a specific parlay recommendation.
{
"parlay_id": "unique_parlay_id"
}- Request Analysis: <1 second
- Full Agent Workflow: 30-60 seconds
- API Response Caching: 30-60 minutes TTL
- Data Persistence: Immediate (file-based)
- CrewAI: Multi-agent orchestration framework
- LangChain: LLM integration and tools
- OpenAI GPT-4: Agent reasoning and decision-making
- Sleeper API: NFL data and player stats
- scikit-learn/XGBoost: ML models
- Python 3.11+: Core language
- Real-time sportsbook odds integration
- Live injury monitoring via X (Twitter)
- Historical parlay performance tracking
- Multi-LLM support (Anthropic Claude)
- Automated bet placement
- Social sentiment analysis
- Database migration from file storage
- API Key Required: OpenAI API key needed for agent execution
- Educational Purpose: For research and learning only
- Data Sources: Currently using Sleeper API (free tier)
- File Storage: All data stored in JSON files (DB-ready architecture)
- Responsible Gaming: This is a tool to aid analysis, not a guarantee of success
Contributions welcome! Please see our contributing guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE file for details.
- Issues: GitHub Issues
- Documentation: See AGENT_SYSTEM_README.md
- Email: Support via GitHub
- CrewAI for the multi-agent framework
- LangChain for LLM tooling
- Sleeper API for NFL data
- OpenAI for GPT-4
Built with AI ๐ค for intelligent sports betting analysis