ESPN Fantasy Baseball — AI-Powered League Manager

Transform your ESPN Fantasy Baseball experience with AI-driven insights and management tools.

ESPN Fantasy Baseball — AI-Powered League Manager

Turn your H2H Categories league into a conversation. Scout opponents, find free agents, analyze trades, run your auction draft, and track your season — all through Claude.

"Who should I pick up at SS this week?"

Claude checks your roster, identifies your weak categories, searches free agents at SS, compares them against your current player, and recommends a pickup that flips two categories in your matchup.

Claude Code

<p align="center"> <img src="assets/demo-claude-code.gif" alt="Demo — Claude Code" width="700"> </p>

OpenClaw

<p align="center"> <img src="assets/demo-openclaw.gif" alt="Demo — OpenClaw" width="350"> </p>

What You Can Do

Weekly Management

  • Matchup scouting — See your H2H category breakdown, identify swing categories, and get lineup recommendations to flip close ones
  • Free agent search — Find pickups filtered by position, ranked by category impact (not generic points)
  • Waiver wire alerts — Monitor league transactions, spot dropped players worth claiming
  • Weekly prep — Full Monday briefing: matchup preview, injury report, start/sit decisions, streaming targets

Trades & Strategy

  • Trade analysis — Evaluate any trade with a category-by-category impact table and a clear accept/decline verdict
  • Category strategy — Map your strengths and weaknesses across all 14 categories, decide what to punt, and build a path to 8+ category wins per week
  • Season outlook — Big-picture analysis: win/loss trajectory, playoff positioning, roster improvement plan

Auction Draft ($280 budget)

  • Live draft board — Track every pick, price paid, and remaining budgets across all teams
  • Budget strategy — Stars-and-scrubs vs balanced, position scarcity alerts (C, SS), nomination targets
  • Bid guidance — For each nominated player: max bid, walk-away price, and alternative targets if you lose

Automated Monitoring (Cron Jobs)

Don't wait until you remember to check — set up scheduled agents to monitor your league on autopilot. Platforms like OpenClaw support cron-based agent execution, so the plugin checks your league on a schedule and alerts you when something needs attention.

Example schedules:

ScheduleWhat it doesCron
Lineup checkFlag injured starters, empty slots, bench players who should startDaily at 8am
Waiver wire scoutMonitor drops, cross-reference with roster needs and weak categoriesEvery 6 hours
Weekly matchup prepScout opponent, identify swing categories, streaming targets, game planMonday 9am

Example prompts for your scheduled agents:

  • "Check my roster for injured players, empty slots, or anyone on the bench who should be starting. Flag any issues."
  • "Check recent league activity for dropped players worth picking up. Cross-reference with my roster needs and weak categories. Only alert me if there's a clear upgrade."
  • "Run a full weekly prep: scout my opponent, identify swing categories, check for streaming pitchers, and give me a game plan for the week."

This turns the plugin from reactive (you ask, it answers) to proactive (it watches your league and tells you when to act).

Cross-Session Memory

The plugin remembers your season across conversations:

What it remembersWhy it matters
Matchup historyWin/loss record per opponent, category breakdowns by week
Category trendsWhich stats you're dominant/weak/improving in over time
Roster movesEvery add, drop, and trade — avoids re-adding players you already tried
WatchlistPlayers you're tracking for future pickup
Draft picksFull auction history with bid amounts
PreferencesYour punt strategy, draft approach, and other strategic decisions

Memory is powered by a local SQLite database (~/.espn-fantasy/memory.db) with 14 MCP tools across 7 tables. At the start of each session, the agent loads your full context — matchup history, category trends, roster moves, and preferences — so it picks up where you left off.

How It Works

Two MCP servers working together:

ESPN Fantasy MCP (30 tools + 5 resources) — Connects to ESPN's API for live league data: rosters, standings, matchups, free agents, player stats, trades, draft board, scoring categories, probable pitchers, and transaction counts. Deployed on Railway via SSE or runs locally via stdio.

Memory MCP (14 tools) — Local SQLite server that persists matchup results, roster moves, category assessments, watchlist, draft picks, and user preferences across sessions. Runs locally via stdio.

8 Skills orchestrate both servers into complete workflows. When you ask "How's my matchup this week?", the matchup-scout skill calls get_standingsget_matchupget_team_roster (opponent) → get_my_roster → loads memory for historical context → produces a category scoreboard with recommendations.

The 14 Scoring Categories

The league uses H2H Categories — you win individual stat categories each week, not total points. This shapes every recommendation:

Hitting (7)Pitching (7)
AVGWHIP (lower wins)
HRERA (lower wins)
OPSK (strikeouts)
R (runs)W (wins)
RBIL (lower wins)
SB (stolen bases)SV (saves)
B_SO (lower wins)HLD (holds)

Built On

  • cwendt94/espn-api — Python library for ESPN's Fantasy API (rosters, standings, matchups, player data). This repo is a fork with the MCP server, CLI, and plugin layered on top.
  • kalil0321/reverse-api-engineer — Captures ESPN browser traffic to discover undocumented API endpoints beyond what espn-api covers. Used to map additional league data and build more powerful tooling.

Quick Start

Prerequisites

  • Python 3.10+
  • uv (curl -LsSf https://astral.sh/uv/install.sh | sh)
  • ESPN Fantasy Baseball account

Setup

git clone https://github.com/garavitgabriel/espn-api.git
cd espn-api
uv sync

Authenticate

Option A — Browser login (easiest):

uv sync --extra browser              # first time only
uv run playwright install chromium   # first time only
uv run espn auth login

A browser opens, you log in to ESPN, and cookies are captured automatically.

Option B — Manual token:

Get your cookies from ESPN Fantasy > DevTools > Application > Cookies, then:

uv run espn auth token <ESPN_S2> <ESPN_SWID>

Option C — .env file:

cp .env.example .env   # edit with your values

Activate

PlatformHow
Claude CodeOpen the project — auto-discovered via .claude-plugin/
Claude DesktopAdd to claude_desktop_config.json (see below)
Claude Coworkuv run espn build-plugin build --target claude --url <SSE_URL>, upload zip
OpenClaw./install-openclaw.sh (see docs/openclaw-setup.md)
<details> <summary>Claude Desktop config</summary>
{
  "mcpServers": {
    "espn-baseball": {
      "command": "uv",
      "args": ["run", "--project", "/path/to/espn-api", "espn-mcp"]
    }
  }
}

File location: ~/Library/Application Support/Claude/claude_desktop_config.json

</details>

Skills

Each skill orchestrates multiple MCP tools into a complete workflow:

SkillTriggersWhat it does
matchup-scout"matchup", "how am I doing", "opponent"Category scoreboard, opponent scouting, press/protect/concede recommendations
free-agent-finder"free agent", "pickup", "waiver"Position-filtered search ranked by category impact, pickup/drop verdicts
trade-analyzer"trade", "should I accept", "give X for Y"Category-by-category impact table, net swing analysis, accept/decline verdict
draft-assistant"draft", "auction", "bid", "budget"Live draft board tracking, bid guidance, budget pacing, position scarcity alerts
weekly-prep"weekly prep", "set my lineup", "Monday briefing"Matchup preview, injury scan, start/sit, streaming targets, week plan
category-strategist"category analysis", "what should I punt"Rate all 14 categories, identify punt targets, build path to 8+ wins
waiver-wire-scout"who got dropped", "league activity"Monitor transactions, spot opportunities, avoid re-adding failed pickups
season-outlook"season outlook", "playoff chances"Win/loss trajectory, category trends, playoff math, improvement plan

CLI

uv run espn standings
uv run espn roster
uv run espn matchup --week 5
uv run espn free-agents --position SS --size 10
uv run espn player "Shohei Ohtani"
uv run espn compare "Shohei Ohtani" "Aaron Judge"
uv run espn trade --give "Player A" --receive "Player B"

# League info
uv run espn schedule --team "Gabriel"
uv run espn settings
uv run espn search "Ohtani"
uv run espn scoreboard --week 5

# Daily lineup decisions
uv run espn probable-pitchers                      # today's MLB starters with handedness
uv run espn sp-schedule "George Kirby"             # next scheduled start
uv run espn vs-team "Freddie Freeman" --opponent SEA  # BvP vs a specific team
uv run espn weekly-moves                           # add/drop count in the current period
uv run espn activity --team "Rolling Bunts" --period 4  # filter league activity

# Draft day
uv run espn scoring
uv run espn slots
uv run espn draft
uv run espn needs

# Auth
uv run espn auth login                        # browser login
uv run espn auth token <ESPN_S2> <ESPN_SWID>  # manual token
uv run espn auth status
uv run espn auth logout

# Plugin bundle
uv run espn build-plugin build --target openclaw
uv run espn build-plugin build --target claude --url https://your-app.up.railway.app/sse

uv run espn --help

MCP Tools (30)

<details> <summary>ESPN Fantasy MCP — live league data</summary>
ToolDescription
get_my_rosterYour team's full roster with stats and injury status
get_team_rosterAny team's roster by name
get_matchupCurrent or specific week matchup with H2H category breakdown
get_standingsLeague standings sorted by rank
get_free_agentsBest available players, filterable by position
get_recent_activityRecent adds, drops, and trades. Optional team_name and scoring_period filters
get_box_scoresAll matchup scores for a week
get_player_infoDetailed stats for any player
compare_playersSide-by-side player comparison
get_league_rostersOverview of all teams' rosters
analyze_tradeEvaluate a trade by comparing give vs receive
get_scoring_categoriesLeague's H2H categories with direction
get_roster_slotsRoster slot configuration
get_draft_boardDraft picks, auction prices, team budgets
get_roster_needsWhich positions you still need to fill
get_scheduleFull season schedule with W/L results, live scores, current week
get_league_settingsComprehensive league config (playoffs, trades, FAAB, divisions, keepers)
search_playerFuzzy player search by partial name
get_scoreboardLightweight matchup view with live scores and winners
refresh_dataPull latest data from ESPN
get_player_newsLatest news, injury blurbs, and next game (via ESPN public API)
get_player_splitsSplits vs LHP/RHP, home/away, by month, by count
get_player_gamelogLast 20 games with full stat lines
get_mlb_gamesMLB games with scores and status for a given date
get_batter_vs_teamBatter's stats vs a specific team's pitchers (accepts explicit opponent_team)
get_pro_scheduleGames-per-team over the next N days — for streaming decisions
get_league_chatLeague message board / trash talk
get_probable_pitchersProbable starters for all MLB games on a date, with handedness (L/R)
get_sp_scheduleA pitcher's next scheduled start — no rotation math required
get_weekly_movesAdd/drop count for a team in a matchup period, with remaining moves
</details> <details> <summary>Memory MCP — cross-session persistence (14 tools)</summary>
ToolDescription
get_full_contextLoad all saved data at session start (matchups, trends, moves, watchlist, preferences)
save_matchup_resultRecord weekly W/L with category breakdown
get_matchup_historyQuery past matchups by opponent, season, or week
save_roster_moveLog adds, drops, trades with notes
get_roster_movesQuery transaction history
add_to_watchlistTrack a player for future pickup
remove_from_watchlistStop tracking a player
get_watchlistView all tracked players
save_category_trendRecord category strength (STRONG/AVERAGE/WEAK) per week
get_category_trendsView category assessments over time
save_draft_pickRecord auction pick with bid amount
get_draft_picksView draft history
set_preferenceStore strategy decisions (punt categories, draft approach)
get_preferencesRetrieve saved preferences
</details> <details> <summary>MCP Resources (5)</summary>
Resource URIDescription
espn://workflow/season-managementWeekly season management playbook
espn://workflow/draft-dayAuction draft day playbook
espn://info/league-settingsH2H Categories format, scoring, roster config
espn://skill/matchup-scoutMatchup analysis workflow
espn://skill/free-agent-finderFree agent search workflow
</details>

Deploy to Railway

The project includes a Dockerfile and railway.json for one-click deployment.

1. Create the service

  1. Push to GitHub
  2. Go to railway.com > New Project > Deploy from GitHub Repo
  3. Select your fork

2. Set environment variables

In the Railway dashboard, add these variables to your service:

VariableValue
ESPN_S2Your ESPN espn_s2 cookie
ESPN_SWIDYour ESPN SWID cookie (include {}curly braces)
ESPN_LEAGUE_IDYour league ID (default: 612122596)
ESPN_YEARSeason year (default: 2026)
ESPN_TEAM_NAMEPartial match for your team name

MCP_TRANSPORT=sse is already baked into the Dockerfile — no need to set it manually.

3. Deploy

Railway auto-builds from the Dockerfile. The railway.json configures:

  • Build: Dockerfile (uv + Python 3.12, layer-cached deps)
  • Start command: /app/.venv/bin/python -m mcp_server.server — uses the venv Python directly (required because Railway may override the Dockerfile CMD)
  • Healthcheck: GET /health with a 60s retry window
  • Restart policy: on failure, up to 3 retries

4. Connect

Once deployed, your endpoints are:

EndpointURL
SSEhttps://your-app.up.railway.app/sse
Healthhttps://your-app.up.railway.app/health

Use the SSE URL in Claude Desktop, Cowork, or any MCP client:

{
  "mcpServers": {
    "espn-baseball": {
      "type": "url",
      "url": "https://your-app.up.railway.app/sse"
    }
  }
}

Note: The startCommand in railway.json is critical. Railway's Dockerfile builder may ignore the CMD instruction and use a dashboard-configured command instead. The explicit startCommand ensures the venv Python (with all dependencies) is always used.


Architecture

espn-api/
├── .claude-plugin/        # Plugin manifest (auto-discovered by Claude Code)
├── .mcp.json              # MCP server registration (uv run)
├── skills/                # 8 agent-invoked skills
├── commands/              # 5 user-invoked slash commands
├── agents/                # fantasy-advisor agent (H2H Categories expert)
├── memory/                # SQLite memory MCP server (14 tools, 7 tables)
│   ├── server.py          # FastMCP server with 14 memory tools
│   ├── db.py              # Schema + connection management
│   └── repos.py           # Repository pattern for each table
├── espn_api/              # Upstream ESPN Fantasy API library
├── mcp_server/            # ESPN MCP server + CLI
│   ├── server.py          # FastMCP server (30 tools + 5 resources)
│   ├── tools.py           # Tool definitions
│   ├── resources.py       # MCP resource definitions (workflow playbooks)
│   ├── formatters.py      # Shared markdown formatters
│   ├── config.py          # League singleton + credential loading
│   ├── auth.py            # ConfigManager (~/.espn-fantasy/config.json)
│   ├── browser_auth.py    # Playwright-based ESPN login
│   ├── espn_public_api.py # ESPN public API client (player, MLB scoreboard)
│   └── cli/               # Typer CLI (mirrors every MCP tool)
├── pyproject.toml         # uv/hatchling package config
├── Dockerfile             # Production container (Railway-ready)
└── install-openclaw.sh    # OpenClaw one-command installer

Development

uv sync --group dev
uv run pytest
uv run espn --help
uv run espn-mcp  # Start MCP server locally

License

Built on cwendt94/espn-api. See upstream repository for license details.