A comprehensive Model Context Protocol (MCP) server providing seamless access to ESPN Fantasy Baseball data through Claude Desktop and other MCP-compatible AI assistants.
Ensure you have Python 3.13+ installed:
# Install Python 3.13 via Homebrew (macOS)
brew install python@3.13
# Verify installation
python3 --version # Should show Python 3.13.xcd espn-api-util
./setup.sh # Create virtual environment and install dependencies./start-dev.sh # Start server in stdio mode for local developmentAsk Claude Desktop to:
Use the metadata_get_positions tool to show available positionsGet league info for league ID [your-league-id]
This server follows a modular architecture optimized for maintainability and extensibility:
auth.py- ESPN authentication (ESPN_S2/SWID cookies)utils.py- League caching, serialization, error handlingmetadata.py- ESPN constant mappings (positions, stats, activities)
league.py- League info, settings, standings, scoreboardroster.py- Team rosters, info, schedulesplayers.py- Player stats, free agents, searchtransactions.py- All transaction types (trades, waivers, add/drop)draft.py- Draft results and analysismatchups.py- Weekly matchups, boxscores
baseball_mcp_server.py- FastMCP server with 40+ registered tools
- Log into your ESPN Fantasy Baseball league
- Open browser developer tools (F12)
- Navigate to Application/Storage β Cookies β espn.com
- Copy values for
ESPN_S2andSWID
Use the auth_store_credentials tool with my ESPN_S2 and SWID cookies.
ESPN_S2: 'your_espn_s2_value'
SWID: 'your_swid_value'
Note: Credentials are session-based and must be re-entered after server restarts.
auth_store_credentials- Store ESPN cookiesauth_logout- Clear stored credentials
league_get_info- Basic league informationleague_get_settings- Detailed league configurationleague_get_standings- Current standingsleague_get_scoreboard- Weekly matchup overview
team_get_roster- Team roster with player detailsteam_get_info- Team metadata and statisticsteam_get_schedule- Season schedule and results
player_get_stats- Individual player statisticsplayer_get_free_agents- Available free agents (filterable)player_get_top_performers- Top performers by categoryplayer_search- Search players by nameplayer_get_waiver_claims- Recent waiver activity
transaction_get_recent_activity- All recent transactionstransaction_get_waiver_activity- Waiver wire movestransaction_get_trade_activity- Trade activitytransaction_get_add_drop_activity- Add/drop transactionstransaction_get_team_transactions- Team-specific transactionstransaction_get_player_history- Player transaction historytransaction_get_lineup_activity- Lineup changestransaction_get_settings_activity- League setting changestransaction_get_keeper_activity- Keeper/dynasty activity
draft_get_results- Complete draft resultsdraft_get_round- Specific round picksdraft_get_team_picks- Team's draft selectionsdraft_get_analysis- Draft statistics and insightsdraft_get_scarcity_analysis- Position scarcity analysis
matchup_get_week_results- Weekly matchup resultsmatchup_get_boxscore- Detailed matchup breakdown
metadata_get_positions- Position ID mappingsmetadata_get_stats- Statistical category mappingsmetadata_get_activity_types- Transaction type mappings
espn-api-util/
βββ baseball_mcp/ # Core MCP server modules
β βββ baseball_mcp_server.py # FastMCP server entry point
β βββ auth.py # ESPN authentication
β βββ league.py # League data tools
β βββ roster.py # Team/roster tools
β βββ players.py # Player analysis tools
β βββ transactions.py # Transaction history tools
β βββ draft.py # Draft analysis tools
β βββ matchups.py # Matchup/scoring tools
β βββ metadata.py # ESPN mappings
β βββ utils.py # Utilities and error handling
βββ .venv/ # Python virtual environment
βββ start-dev.sh # Development server launcher
βββ setup.sh # Environment setup script
βββ setup_claude_desktop.sh # Claude Desktop configuration
βββ pyproject.toml # Project dependencies
- Implement function in appropriate module (e.g.,
players.py) - Register tool in
baseball_mcp_server.pyusing@mcp.tool() - Follow existing error handling patterns
- Test with
./start-dev.sh
./start-dev.sh # Development server with console output- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/claude-desktop/claude_desktop_config.json
{
"globalShortcut": "Ctrl+Space",
"mcpServers": {
"espn-baseball": {
"command": "/path/to/espn-api-util/start-dev.sh"
}
}
}Important: Ensure proper JSON syntax - missing commas are a common cause of configuration failures. Validate your JSON using python3 -m json.tool config_file.json.
Get league 123456 standings:
β league_get_standings(league_id=123456)
Check this week's matchups:
β league_get_scoreboard(league_id=123456)
View team 1's roster:
β team_get_roster(league_id=123456, team_id=1)
Check their recent moves:
β transaction_get_team_transactions(league_id=123456, team_id=1)
Find available catchers:
β player_get_free_agents(league_id=123456, position="C", limit=20)
Search for Mike Trout:
β player_search(league_id=123456, query="Mike Trout")
Review complete draft:
β draft_get_results(league_id=123456)
Analyze position scarcity:
β draft_get_scarcity_analysis(league_id=123456)
| Issue | Solution |
|---|---|
| "Python 3.13 required" | Install Python 3.13+: brew install python@3.13 |
| "Server not in Claude" | Run ./setup.sh, configure Claude Desktop manually, restart Claude Desktop |
| "ModuleNotFoundError: mcp" | Run ./setup.sh to install dependencies in virtual environment |
| "Authentication failed" | Re-authenticate with auth_store_credentials tool |
| "Tool not working" | Verify parameters and ensure authentication for private leagues |
| "Python import error" | Run ./setup.sh to set up virtual environment |
| "Permission denied" | Run chmod +x start-dev.sh to make script executable |
| "JSON syntax error" | Verify Claude Desktop config has proper commas and brackets |
- Python: 3.13+
- Dependencies:
espn-api>=0.45.0,mcp[cli]>=1.5.0,rapidfuzz>=3.0.0 - Optional: Claude Desktop for AI integration
- Baseball Only: This server is specifically for ESPN Fantasy Baseball
- Python 3.13 Required: Uses latest stable Python version (3.13+) for optimal performance
- Session-Based Auth: Credentials don't persist across server restarts
- ESPN API Limits: Be mindful of request rate limits
- Current Year: Uses current calendar year for baseball season (2025)
MIT License - see LICENSE file for details.
- Built on cwendt94/espn-api
- Uses Anthropic MCP framework