Skip to main content
Glama
espn-fantasy-football-mcp

espn-fantasy-football-mcp

by heyitaki

espn-fantasy-football-mcp

A TypeScript MCP server for ESPN fantasy football over stdio. Read league settings, rosters, available players, matchups and transactions. Update lineups, add or drop players, and manage waiver claims.

Tools return readable text and structured results. Player tables include ESPN ids, slots, opponents, injuries and projected points. Missing statistics are null, distinct from a recorded or projected zero. Text displays missing values as - and points to one decimal.

Install

Requires Node.js 22.12 or newer and npm. From a checkout of this repository:

npm install && npm run build

Run the built server with your league id:

ESPN_LEAGUE_ID=123456 ESPN_READ_ONLY=1 node dist/index.js

The server waits for an MCP client on stdin. It does not provide an interactive command prompt. Stdout carries only MCP messages. Startup errors go to stderr.

Related MCP server: yahoo-fantasy-mcp

Configuration

Supply environment variables to the server process:

Variable

Required

Meaning and default

ESPN_LEAGUE_ID

Yes

Integer league id from the league URL's leagueId parameter.

ESPN_SEASON

No

Integer NFL season year. Defaults to the current calendar year. Set it explicitly when viewing a season after New Year's Day.

ESPN_TEAM_ID

No

Integer fantasy team id from your team's URL. Used when a tool omits teamId.

ESPN_S2

Private reads and all writes

The espn_s2 cookie value, kept URL-encoded.

ESPN_SWID

Private reads and all writes

The SWID cookie value, including braces. Also identifies the member making a transaction.

ESPN_READ_ONLY

No

1 or true disables every write tool, including dry runs. Defaults to false.

Credentials are trimmed at the edges but are never URL-decoded. Cookies are sent only when both values are present. Public leagues can be read without credentials. A private league usually returns a 401 error when cookies are missing or expired.

Claude Code

Register a public league in read-only mode. Replace the path and ids with your own:

claude mcp add --transport stdio --scope user \
  -e ESPN_LEAGUE_ID=123456 -e ESPN_SEASON=2026 \
  -e ESPN_TEAM_ID=1 -e ESPN_READ_ONLY=1 \
  espn-fantasy-football -- node /absolute/path/espn-fantasy-football-mcp/dist/index.js

For a private league, supply ESPN_S2 and ESPN_SWID through the server's environment using your client's local secret configuration or a launcher that reads your secret manager. Keep credentials out of shared project configuration.

Generic MCP client

Most stdio clients accept a configuration shaped like this:

{
  "mcpServers": {
    "espn-fantasy-football": {
      "command": "node",
      "args": ["/absolute/path/espn-fantasy-football-mcp/dist/index.js"],
      "env": {
        "ESPN_LEAGUE_ID": "123456",
        "ESPN_SEASON": "2026",
        "ESPN_TEAM_ID": "1",
        "ESPN_READ_ONLY": "1"
      }
    }
  }
}

Clients launched from a desktop may need an absolute path to node. Restart the MCP server after changing its environment.

Tools

? marks an optional argument. teamId means an ESPN fantasy team id, not an NFL team id. Player ids are ESPN ids. D/ST ids are negative: Chargers D/ST is -16024, following -16000 - proTeamId.

week defaults to the league's current NFL scoringPeriodId. Tools that need a team use the argument or ESPN_TEAM_ID and return an error if neither is set. Limits must be positive integers.

Tool

Arguments

Result and use

get_league

None

League settings, lineup slot counts, waiver and trade rules, and teams with owners, records and waiver ranks.

get_roster

teamId?, week?

Team name and roster, ordered by starting slot, then bench and IR. Includes eligibility, bye weeks, opponents, kickoff times, injuries, ownership and weekly/season points.

get_free_agents

positions?, limit? (50, max 200), sortBy? (percentOwned, percentChange, projected), week?

Free agents and waiver players with availability and ranks. Positions: QB, RB, WR, TE, K, D/ST. Default sort is percent owned, descending.

search_players

query, limit? (10)

Name substring search across rosters and ESPN's player pool. Returns status and fantasy team ownership, deduplicated by player id with rostered matches first.

get_matchups

week?

Scores and live projections with team names. mine identifies the configured team's matchup.

get_transactions

limit? (25)

Recent transactions, newest first, including ids, status, bids, dates and item player ids. ESPN does not include player names in this view.

set_lineup

moves: [{playerId, slot}], teamId?, week?, dryRun?

One roster transaction for all listed moves. Checks each player's current slot and eligibility.

add_player

playerId, dropPlayerId?, teamId?, week?, dryRun?

Add a free agent, optionally dropping another player in the same transaction.

drop_player

playerId, teamId?, week?, dryRun?

Drop one rostered player.

submit_waiver_claim

playerId, dropPlayerId?, bid? (0), teamId?, week?, dryRun?

Submit a waiver claim with an optional drop. Bid must be a nonnegative integer.

cancel_waiver_claim

transactionId, teamId?, week?, dryRun?

Cancel a pending claim using its transaction id from get_transactions.

Every write returns { dryRun, payload, result? }. dryRun: true previews the exact payload without posting, but still requires credentials and may fetch current league data. The default is false, which submits immediately. ESPN enforces ownership, locks, roster capacity, budgets and waiver rules. A preview does not guarantee ESPN will accept the transaction later.

Lineup slot names are case-sensitive. Use eligibleSlots from get_roster, such as QB, RB, WR, TE, FLEX, OP, D/ST, K, BE or IR. To swap players, list both moves. The server never adds counter-moves. Unknown position and slot ids display as POS<id> and SLOT<id>.

Validation and ESPN errors return isError: true with a text message. Check transaction status before repeating a write after a connection failure, since ESPN may already have processed it.

Credentials and security

espn_s2 is a full account session. Never commit it or paste it into chats. Treat it like a password, and protect SWID too.

To find the cookies:

  1. Sign in to ESPN and open your league on fantasy.espn.com.

  2. Open browser DevTools, then Application, Storage, Cookies.

  3. Select the ESPN cookie store for the page and locate espn_s2 and SWID.

  4. Copy their values into a secret manager or private local configuration. Preserve URL encoding and braces. Refresh them there if the session expires.

ESPN_READ_ONLY=1 disables every write tool before any fetch, even with dryRun: true. Enable writes only for a trusted MCP client and review the requested moves. The server does not ask for confirmation before submitting. The configured team is a default, not an access restriction, and the cookies may authorize actions beyond that team.

The server sends credentials only to the configured ESPN hosts and refuses redirects. It does not save credentials or league data to disk. Your MCP client can retain tool results, including team/member ids and transaction payloads, so protect its history and logs as well.

API and development

ESPN's fantasy API is unofficial and can change without notice. Reads use lm-api-reads.fantasy.espn.com. Writes use lm-api-writes.fantasy.espn.com. This project is not affiliated with ESPN.

Payload builders live in src/espn/transactions.ts. ESPN ids, views, filter sort keys, endpoints and protocol constants live in src/espn/constants.ts. Only the NFL team schedule index is cached, per server instance. Other data is fetched for each tool call. There are no automatic retries.

npm run typecheck
npm test
npm run build

The tests inject fetch and use local fixtures. They do not contact ESPN. CI runs these checks on Node 24. On Node 22.12 through 22.17, direct TypeScript test execution requires NODE_OPTIONS=--experimental-strip-types; compiled server execution does not.

License

MIT. See LICENSE.

Available Tools

11 tools
add_playerAdd a free agentA
Destructive

Add an available free agent, optionally dropping a rostered player in the same transaction. Use submit_waiver_claim for players on waivers. Player ids are ESPN ids, including negative D/ST ids. teamId is an ESPN fantasy team id and defaults to ESPN_TEAM_ID. week defaults to the current NFL week. dryRun previews the payload without posting. Requires ESPN_S2 and ESPN_SWID.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
dryRunNoPreview the payload without posting it to ESPN.
teamIdNoESPN fantasy team id, defaults to ESPN_TEAM_ID.
playerIdYesESPN player id. D/ST ids are negative, such as -16024 for the Chargers.
dropPlayerIdNoESPN player id. D/ST ids are negative, such as -16024 for the Chargers.

Output Schema

NameRequiredDescription
dryRunYes
resultNo
payloadYes
cancel_waiver_claimCancel a waiver claimA
Destructive

Cancel a pending waiver claim using its ESPN transactionId from get_transactions. teamId is an ESPN fantasy team id and defaults to ESPN_TEAM_ID. week defaults to the current NFL week. dryRun previews the payload without posting. Requires ESPN_S2 and ESPN_SWID.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
dryRunNoPreview the payload without posting it to ESPN.
teamIdNoESPN fantasy team id, defaults to ESPN_TEAM_ID.
transactionIdYes

Output Schema

NameRequiredDescription
dryRunYes
resultNo
payloadYes
drop_playerDrop a rostered playerA
Destructive

Release one player from your fantasy team. ESPN enforces roster locks and league rules. Player ids are ESPN ids, including negative D/ST ids. teamId is an ESPN fantasy team id and defaults to ESPN_TEAM_ID. week defaults to the current NFL week. dryRun previews the payload without posting. Requires ESPN_S2 and ESPN_SWID.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
dryRunNoPreview the payload without posting it to ESPN.
teamIdNoESPN fantasy team id, defaults to ESPN_TEAM_ID.
playerIdYesESPN player id. D/ST ids are negative, such as -16024 for the Chargers.

Output Schema

NameRequiredDescription
dryRunYes
resultNo
payloadYes
get_free_agentsFree agents and waiversA
Read-only

Find available players to add or claim, with optional position filters and ownership or projection sorting. Player ids are ESPN ids, including negative D/ST ids.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
limitNo
sortByNopercentOwned
positionsNo

Output Schema

NameRequiredDescription
weekYes
playersYes
get_leagueLeague and standingsA
Read-only

Inspect league settings, lineup slots, waiver rules and team standings before managing a team. Team ids identify ESPN fantasy teams.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
teamsYes
leagueYes
get_matchupsWeekly matchupsA
Read-only

Check scores and live projections for a week, with the configured team's matchup marked mine. Team ids are ESPN fantasy team ids.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.

Output Schema

NameRequiredDescription
weekYes
matchupsYes
get_rosterTeam rosterA
Read-only

Inspect a team's lineup, eligible slots, injuries, opponents and projections before making moves. teamId is an ESPN fantasy team id and defaults to ESPN_TEAM_ID. Player ids are ESPN ids, including negative D/ST ids.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
teamIdNoESPN fantasy team id, defaults to ESPN_TEAM_ID.

Output Schema

NameRequiredDescription
weekYes
teamIdYes
playersYes
teamNameYes
get_transactionsRecent transactionsA
Read-only

Inspect recent league activity, newest first, and find transaction ids for cancelling pending claims. Items contain ESPN player ids only, without names. Player ids are ESPN ids, including negative D/ST ids.

NameRequiredDescriptionDefault
limitNo

Output Schema

NameRequiredDescription
transactionsYes
search_playersSearch playersA
Read-only

Look up ESPN player ids and fantasy team ownership by a case-insensitive name substring, across rosters, free agents and waivers. Player ids are ESPN ids, including negative D/ST ids.

NameRequiredDescriptionDefault
limitNo
queryYes

Output Schema

NameRequiredDescription
playersYes
set_lineupMove lineup playersA
Destructive

Move rostered players to eligible slots such as QB, FLEX, BE or IR. List every move, including the player leaving an occupied slot. No counter-moves are added. Player ids are ESPN ids, including negative D/ST ids. teamId is an ESPN fantasy team id and defaults to ESPN_TEAM_ID. week defaults to the current NFL week. dryRun previews the payload without posting. Requires ESPN_S2 and ESPN_SWID.

NameRequiredDescriptionDefault
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
movesYes
dryRunNoPreview the payload without posting it to ESPN.
teamIdNoESPN fantasy team id, defaults to ESPN_TEAM_ID.

Output Schema

NameRequiredDescription
dryRunYes
resultNo
payloadYes
submit_waiver_claimSubmit a waiver claimA
Destructive

Claim a player on waivers with an optional drop and a nonnegative bid, defaulting to 0. ESPN processes the claim under league rules. Player ids are ESPN ids, including negative D/ST ids. teamId is an ESPN fantasy team id and defaults to ESPN_TEAM_ID. week defaults to the current NFL week. dryRun previews the payload without posting. Requires ESPN_S2 and ESPN_SWID.

NameRequiredDescriptionDefault
bidNo
weekNoNFL scoring week, defaults to the league's current scoringPeriodId.
dryRunNoPreview the payload without posting it to ESPN.
teamIdNoESPN fantasy team id, defaults to ESPN_TEAM_ID.
playerIdYesESPN player id. D/ST ids are negative, such as -16024 for the Chargers.
dropPlayerIdNoESPN player id. D/ST ids are negative, such as -16024 for the Chargers.

Output Schema

NameRequiredDescription
dryRunYes
resultNo
payloadYes

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 11 tool updatesv0.1.0
    • First observedadd_player
    • First observedcancel_waiver_claim
    • First observeddrop_player
    • First observedget_free_agents
    • First observedget_league
    • First observedget_matchups
    • First observedget_roster
    • First observedget_transactions
    • First observedsearch_players
    • First observedset_lineup
    • First observedsubmit_waiver_claim

TDQS

A4.1/5.0

Scored across 11 tools

Disambiguation4/5

Most tools target distinct actions and resources: get_* tools cover reads while add/drop/set_lineup and waiver tools cover writes. The main potential confusion is between add_player and submit_waiver_claim, and between search_players and get_free_agents, but the descriptions clearly separate free agents from waivers and lookup from listing.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern, such as get_league, set_lineup, drop_player, and cancel_waiver_claim. The verb choices are predictable and match the operation performed.

Tool Count5/5

11 tools is well-scoped for a fantasy football management server, covering league info, rosters, players, transactions, lineup changes, and waiver operations. Each tool addresses a distinct core workflow without unnecessary bloat.

Completeness4/5

The tool set covers the major fantasy football workflows: viewing league/roster/matchup data, searching and adding players, setting lineups, and managing waiver claims. A notable gap is lack of trade support, which is a common fantasy football operation, but the core management lifecycle is otherwise complete.

Maintenance

ActivityStale
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides read-only access to Sleeper fantasy football leagues, enabling team snapshots, available players, matchups, trade context, and league history through standardized MCP tools.
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    Enables querying Yahoo Fantasy Sports leagues, rosters, and matchups via an MCP interface (read-only).
    10
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides read-only access to Sleeper fantasy football data including user info, leagues, rosters, matchups, and NFL state through MCP tools.
    135 npm
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Provides local MCP tools for fantasy football draft simulation, weekly lineup decisions, and configurable automation policies.
    17
    40 PyPI
    88
    MIT