Skip to main content
Glama
README.md
# SleeperMCP: a fantasy football GM for your AI assistant

An MCP (Model Context Protocol) server that connects Claude, or any MCP client,
to your [Sleeper](https://sleeper.com) fantasy football leagues. It exposes 12
read-only tools backed by Sleeper's public API, plus a built-in "GM playbook"
that tells the assistant how to use them: when to scout waivers, how to weigh
projections against recent form, and what to check before kickoff.

Ask things like "Who should I start at flex?" or "Anyone good on waivers?" and
get an answer grounded in your real roster, matchup and league.

No Sleeper API key is needed. Sleeper's public API is read-only, so the server
can't change your lineup or make moves; you still do that in the app.

---

## Tools

| Tool | What it does |
|

---

## Run it locally (Claude Desktop)

1. Install [uv](https://docs.astral.sh/uv/).
2. Clone this repo:
   ```bash
   git clone https://github.com/hellojeremyq-pixel/SleeperMCP.git
   ```
3. Add this to `~/Library/Application Support/Claude/claude_desktop_config.json`
   (use the full path; the config doesn't expand `~`):
   ```json
   {
     "mcpServers": {
       "sleeperMCP": {
         "command": "uv",
         "args": [
           "run", "--with", "fastmcp", "--with", "httpx",
           "/full/path/to/SleeperMCP/sleeper_server.py"
         ],
         "env": {
           "SLEEPER_USERNAME": "yourname",
           "SLEEPER_LEAGUE_ID": "1234567890"
         }
       }
     }
   }
   ```
4. Fully quit and reopen Claude Desktop. The 12 tools appear automatically.

**Finding your values:** your username is under your avatar in the Sleeper app.
Your league ID is in the league's URL: `https://sleeper.com/leagues/<LEAGUE_ID>/...`.
`SLEEPER_LEAGUE_ID` is just the default; every tool also takes a `league_id`,
and `list_my_leagues` finds all of yours.

**Or run it directly:**
```bash
pip install -r requirements.txt
cp .env.example .env   # fill in your values, or export them in your shell
SLEEPER_USERNAME=yourname SLEEPER_LEAGUE_ID=1234567890 python sleeper_server.py
```

**Smoke test** (calls every tool against your league):
```bash
SLEEPER_USERNAME=yourname SLEEPER_LEAGUE_ID=1234567890 python _smoke_test.py
```

---

## Deploy as a remote MCP (Vercel)

`main.py` serves the same tools over Streamable HTTP, for clients that connect
to a URL instead of running a local process.

1. Import the repo into Vercel.
2. Set environment variables: `SLEEPER_USERNAME`, `SLEEPER_LEAGUE_ID`, and
   `MCP_PATH_SECRET` (a long random string, e.g. `openssl rand -hex 24`).
3. Your endpoint is `https://<your-app>.vercel.app/<MCP_PATH_SECRET>/mcp`.
   Every other path returns 404.

---

## How it thinks

The MCP loads with a GM playbook in its `instructions` field that tells Claude
to act as your fantasy GM — including a day-of-week routine (Tuesday: review
MNF + waiver scout; Wednesday: confirm waiver claims; Thursday: TNF lineup
check; Sunday morning: final lineup; etc.). Just ask things like:

- "What should I do today?"
- "Who should I start at flex this week?"
- "Anyone good on waivers?"
- "How do I match up against my opponent?"

---

---

## Security

- **Read-only.** The server only reads from Sleeper's public API.
- **No secrets in code.** Your username, league ID and path secret come from
  environment variables. `.env` is gitignored; `.env.example` shows the shape.
- **Treat the remote URL like a password.** Some MCP clients don't support
  bearer tokens, so the remote deploy is protected by the secret path segment.
  Anyone with the full URL can read your league data (which Sleeper already
  makes public), so don't post it. To revoke access, change `MCP_PATH_SECRET`.

---

## Notes

- Player metadata is cached at `.cache/players.json` (~5MB) and refreshed every 24 hours.
- League settings are cached for the server's lifetime; restart it to pick up changes.

## License

MIT. See [LICENSE](LICENSE).