Production-grade MCP server for Yahoo Fantasy Sports with sophisticated lineup optimization
Project description
Fantasy Football MCP Server
A comprehensive Model Context Protocol (MCP) server for Yahoo Fantasy Football that provides intelligent lineup optimization, draft assistance, and league management through AI-powered tools.
๐ Features
Core Capabilities
- Multi-League Support โ Automatically discovers and manages all Yahoo Fantasy Football leagues associated with your account
- ๐ Player Enhancement Layer โ Intelligent projection adjustments with bye week detection, recent performance stats, and breakout/declining player flags
- Intelligent Lineup Optimization โ Advanced algorithms considering matchups, expert projections, and position-normalized value
- Draft Assistant โ Real-time draft recommendations with strategy-based analysis and VORP calculations
- Comprehensive Analytics โ Reddit sentiment analysis, team comparisons, and performance metrics
- Multiple Deployment Options โ FastMCP, traditional MCP, Docker, and cloud deployment support
Advanced Analytics
- Position Normalization โ Smart FLEX decisions accounting for different position baselines
- Multi-Source Projections โ Combines Yahoo and Sleeper expert rankings with matchup analysis
- Strategy-Based Optimization โ Conservative, aggressive, and balanced approaches
- Volatility Scoring โ Floor vs ceiling analysis for consistent or boom-bust plays
- Live Draft Support โ Real-time recommendations during active drafts
๐ Player Enhancement Layer
The enhancement layer enriches player data with real-world context to fix stale projections and prevent common mistakes:
Key Features
โ Bye Week Detection โ Automatically zeros projections and displays "BYE WEEK - DO NOT START" for players on bye, preventing accidental starts
โ Recent Performance Stats โ Fetches last 1-3 weeks of actual performance from Sleeper API and displays trends (L3W avg: X.X pts/game)
โ Performance Flags โ Intelligent alerts including:
BREAKOUT_CANDIDATEโ Recent performance > 150% of projectionTRENDING_UPโ Recent performance exceeds projectionDECLINING_ROLEโ Recent performance < 70% of projectionHIGH_CEILINGโ Explosive upside potentialCONSISTENTโ Reliable, steady performance
โ Adjusted Projections โ Blends recent reality with stale projections for more accurate start/sit decisions (60/40 or 70/30 weighting based on confidence)
Example
Before Enhancement:
{
"name": "Rico Dowdle",
"sleeper_projection": 4.0,
"recommendation": "Bench"
}
After Enhancement:
{
"name": "Rico Dowdle",
"sleeper_projection": 4.0,
"adjusted_projection": 14.8,
"performance_flags": ["BREAKOUT_CANDIDATE", "TRENDING_UP"],
"enhancement_context": "Recent breakout: averaging 18.5 pts over last 3 weeks",
"recommendation": "Strong Start"
}
The enhancement layer is non-breaking and automatically applies to:
ff_get_roster(withinclude_external_data=True)ff_get_waiver_wire(withinclude_external_data=True)ff_get_players(withinclude_external_data=True)ff_build_lineup(automatic)
๐ ๏ธ Available MCP Tools
League & Team Management
ff_get_leaguesโ List all leagues for your authenticated Yahoo accountff_get_league_infoโ Retrieve detailed league metadata and team informationff_get_standingsโ View current league standings with wins, losses, and pointsff_get_rosterโ Inspect detailed roster information for any teamff_get_matchupโ Analyze weekly matchup details and projectionsff_compare_teamsโ Side-by-side team roster comparisons for trades/analysisff_build_lineupโ Generate optimal lineups using advanced optimization algorithms
Player Discovery & Waiver Wire
ff_get_playersโ Browse available free agents with ownership percentagesff_get_waiver_wireโ Smart waiver wire targets with expert analysis (configurable count)ff_get_draft_rankingsโ Access Yahoo's pre-draft rankings and ADP data
Draft Assistant Tools
ff_get_draft_recommendationโ AI-powered draft pick suggestions with strategy analysisff_analyze_draft_stateโ Real-time roster needs and positional analysis during draftsff_get_draft_resultsโ Post-draft analysis with grades and team summaries
Advanced Analytics
ff_analyze_reddit_sentimentโ Social media sentiment analysis for player buzz and injury updatesff_get_api_statusโ Monitor cache performance and Yahoo API rate limitingff_clear_cacheโ Clear cached responses for fresh data (with pattern support)ff_refresh_tokenโ Automatically refresh Yahoo OAuth tokens
๐ฆ Installation
Quick Start
git clone https://github.com/derekrbreese/fantasy-football-mcp-public.git
cd fantasy-football-mcp-public
pip install -r requirements.txt
Yahoo API Setup
- Create a Yahoo Developer App at developer.yahoo.com
- Note your Consumer Key (Client ID) and Consumer Secret (Client Secret)
- Set up your
.envfile with these credentials - Complete OAuth flow using the included authentication scripts
โ๏ธ Configuration
Create a .env file with your API credentials:
# Yahoo API Credentials (Required)
YAHOO_CLIENT_ID=your_consumer_key_here
YAHOO_CLIENT_SECRET=your_consumer_secret_here
YAHOO_ACCESS_TOKEN=your_access_token
YAHOO_REFRESH_TOKEN=your_refresh_token
YAHOO_GUID=your_yahoo_guid
# Reddit API Credentials (Optional - for sentiment analysis)
REDDIT_CLIENT_ID=your_reddit_client_id
REDDIT_CLIENT_SECRET=your_reddit_client_secret
REDDIT_USERNAME=your_reddit_username
Note: Reddit credentials are optional. The app will work without them, but Reddit sentiment analysis features will be unavailable. See Reddit API Setup Guide for detailed instructions.
Initial Authentication
First-time setup:
cd utils
python setup_yahoo_auth.py
Re-authentication (if tokens expired):
cd utils
python reauth_yahoo.py
Token refresh (when access token expires):
cd utils
python refresh_yahoo_token.py
The authentication scripts will:
- Open your browser for Yahoo OAuth authorization
- Automatically update your
.envfile (preserving existing variable line positions) - Automatically update MCP config files (Claude Desktop, Cursor, Antigravity) if they exist
- Display confirmation messages
Important: After authentication or token refresh, restart your MCP client to use the new tokens.
๐ Deployment Options
Local Development (FastMCP)
python fastmcp_server.py
Connect via HTTP transport at http://localhost:8000
Claude Code Integration (Stdio)
python fantasy_football_multi_league.py
Docker Deployment
docker build -t fantasy-football-mcp .
docker run -p 8080:8080 --env-file .env fantasy-football-mcp
Cloud Deployment (Render/Railway/etc.)
The server includes multiple compatibility layers for various cloud platforms:
render_server.py- Render.com deploymentsimple_mcp_server.py- Generic HTTP/WebSocket serverfastmcp_server.py- FastMCP cloud deployments
๐งช Testing
# Run full test suite
pytest
# Test OAuth authentication
python tests/test_oauth.py
# Test MCP connection
python tests/test_mcp_client.py
๐ Project Structure
fantasy-football-mcp-public/
โโโ fastmcp_server.py # FastMCP HTTP server implementation
โโโ fantasy_football_multi_league.py # Main MCP stdio server
โโโ lineup_optimizer.py # Advanced lineup optimization engine
โโโ matchup_analyzer.py # Defensive matchup analysis
โโโ position_normalizer.py # FLEX position value calculations
โโโ src/
โ โโโ agents/ # Specialized analysis agents
โ โโโ models/ # Data models for players, lineups, drafts
โ โโโ strategies/ # Draft and lineup strategies
โ โโโ services/ # Player enhancement and external integrations
โ โโโ utils/ # Utility functions and configurations
โโโ tests/ # Comprehensive test suite
โโโ utils/ # Authentication and token management
โโโ requirements.txt # Python dependencies
๐ง Advanced Configuration
Strategy Weights (Balanced Default)
{
"yahoo": 0.40, # Yahoo expert projections
"sleeper": 0.40, # Sleeper expert rankings
"matchup": 0.10, # Defensive matchup analysis
"trending": 0.05, # Player trending data
"momentum": 0.05 # Recent performance
}
Draft Strategies
- Conservative: Prioritize proven players, minimize risk
- Aggressive: Target high-upside breakout candidates
- Balanced: Optimal mix of safety and ceiling potential
Position Scoring Baselines
- RB: ~11 points (standard scoring)
- WR: ~10 points (standard scoring)
- TE: ~7 points (standard scoring)
- FLEX calculations include position scarcity adjustments
๐ Performance Metrics
The optimization engine targets:
- 85%+ accuracy on start/sit decisions
- +2.0 points per optimal decision on average
- 90%+ lineup efficiency vs. manual selection
- Position-normalized FLEX decisions to avoid TE traps
๐ Troubleshooting
Common Issues
Authentication Errors
# Refresh expired tokens (expire hourly)
cd utils
python refresh_yahoo_token.py
# Full re-authentication if refresh fails
cd utils
python reauth_yahoo.py
# Or first-time setup
cd utils
python setup_yahoo_auth.py
Note: All authentication scripts automatically update your .env file and MCP config files. After running any authentication script, restart your MCP client (Claude Desktop, Cursor, etc.) to use the new tokens.
Only One League Showing
- Verify
YAHOO_GUIDmatches your Yahoo account - Ensure leagues are active for current season
- Check team ownership detection in logs
Rate Limiting
- Yahoo allows 1000 requests/hour
- Server implements 900/hour safety limit
- Use
ff_get_api_statusto monitor usage - Clear cache with
ff_clear_cacheif needed
Stale Data
- Cache TTLs: Leagues (1hr), Standings (5min), Players (15min)
- Force refresh with
ff_clear_cachetool - Check last update times in
ff_get_api_status
๐ค Contributing
This is the public version of the Fantasy Football MCP Server. For contributing:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
๐ License
MIT License - see LICENSE file for details
๐ Acknowledgments
- Yahoo Fantasy Sports API for comprehensive league data
- Sleeper API for expert rankings and defensive analysis
- Reddit API for player sentiment analysis
- Model Context Protocol (MCP) framework
Note: This server requires active Yahoo Fantasy Football leagues and valid API credentials. Ensure you have proper authorization before accessing league data.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_derekrbreese_fantasy_football_mcp-1.0.1.tar.gz.
File metadata
- Download URL: iflow_mcp_derekrbreese_fantasy_football_mcp-1.0.1.tar.gz
- Upload date:
- Size: 278.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21528582c16b4c81328b36f11f33d1b73e9b19a46daf8ec5eb17fc3152a5845f
|
|
| MD5 |
4a8d2df1951181232f068e81b37ef0c2
|
|
| BLAKE2b-256 |
9a36e09e8937d55c0b3006910b644d86b79dff832bb3558f2950da588f218d86
|
File details
Details for the file iflow_mcp_derekrbreese_fantasy_football_mcp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_derekrbreese_fantasy_football_mcp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 223.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6834b36742c001999ca2d1d9e81c53c3a5c8e9db9c09662ad59fc49ef9485c2b
|
|
| MD5 |
c14d3c4aeba0b92d6b7dcae3debe0477
|
|
| BLAKE2b-256 |
3e383fbb0368c4187d09d052a569c5adf827c960fc573413ebde34e06b32f7a4
|