# Connect an agent to AI Hockey

Give Claude, ChatGPT, Cursor, or any other agent read access to your fantasy pools. Use your own AI to analyze the data. AI Hockey’s AI features are available only in the webapp.

## 1. Unlock your seat

Agent access is per pool seat, not per account.

1. Open **Settings → AI agents**.
2. Unlock the seat (one-time checkout) or ask an AI Hockey admin to grant it.
3. Levels: **READ** (standings, rosters, digests, insights), **ASSIST** (reads plus separately authorized private queue edits), **FULL** (also making draft picks with explicit write approval).

## 2. Connect the agent

On **Settings → AI agents**, copy the MCP URL:

```text
https://ai-hockey.com/mcp
```

Add it as a remote MCP server. The agent signs you in and shows a consent screen. Consent lists unlocked seats unchecked. Leave write off unless the agent asked for write, the seat is FULL, and you want draft picks. A scope you did not request is not added. In a box pool that hides picks, the agent sees your own roster and the standings totals, not other members' player names.

- Cursor: use **Add to Cursor** on the settings page, or install a remote MCP server with that URL. Do not put a token in `mcp.json`.
- Claude: Settings → Connectors → Add custom connector, then paste the MCP URL.
- Grok: add a remote MCP server with the same URL.

The prompt on the settings page contains the URL only.

Script tokens (`aih_…`) stay on that page for your own programs. They are shown once, stored as a hash, and must not be pasted into a chat.

## 3. REST

Base URL: `https://ai-hockey.com/api/agent/v1`

```http
Authorization: Bearer aih_…
```

| Method | Path | Scope |
|---|---|---|
| GET | `/me` | any |
| GET | `/pools` | `pool:read` |
| GET | `/pools/{poolId}/standings?includeRemaining=` | `pool:read` |
| GET | `/pools/{poolId}/live-roster?participantId=&nhlDay=&limit=` | `pool:read` |
| GET | `/pools/{poolId}/tonight?topN=` | `pool:read` |
| GET | `/pools/{poolId}/compare?participantIds=id1,id2` | `pool:read` |
| GET | `/pools/{poolId}/schedule?fromNhlDay=&toNhlDay=` | `pool:read` |
| GET | `/pools/{poolId}/roster?participantId=` | `pool:read` |
| GET | `/pools/{poolId}/digest/daily?nhlDay=YYYY-MM-DD` | `digest:read` |
| GET | `/pools/{poolId}/digest/weekly?endNhlDay=` | `digest:read` |
| GET | `/pools/{poolId}/insights` | `stats:read` |
| GET | `/pools/{poolId}/draft` | `pool:read` |
| GET | `/pools/{poolId}/draft/candidates?type=player&q=` | `pool:read` |
| POST | `/pools/{poolId}/draft/picks` | `draft:pick` |

`nhlDay` defaults to the most recent completed NHL day. A weekly digest is the 7 NHL days ending on `endNhlDay`.

Pass `seatId` only if you hold more than one seat in that pool.

Success responses are `{ "data": … }`. Errors are `{ "error": { "code", "message" } }` with status 400, 401, 402 (seat locked or pool hosting locked), 403, 404, 409, or 429. On 429, wait `Retry-After` seconds. Limit is 60 requests per minute per token.

Agent endpoints do not run AI features, return cached AI briefings, or spend AI wallet funds. A digest also includes `isComplete`, `gamesRemaining`, top scorers on each roster, and current injuries.

Live detail (all read-only, current NHL day unless `nhlDay` is set):

- `GET /pools/{poolId}/live-roster` — one roster. Each pick has the opponent, home/away, `startsAt` (ISO 8601 with an Eastern offset), game state (`scheduled`, `live`, `intermission`, `final`, `postponed`), score, fantasy points, stat line, injury flags, season points, and last-7 points.
- `GET /pools/{poolId}/tonight` — one call for the race: your rank, tonight’s points, total, `gapToFirst`, `gapToNext`, remaining names with game score and clock, your top scorers, rival contributors, lead changes, and `upsideRemaining` (per-game average of picks still to play). `topN` defaults to 5. `climbers`, `fallers`, and `scorers` are the web app’s Top 3 (today’s DAY `rankChange`, and tonight pool points). `rivals` is the neighbourhood around your rank, not only the first `topN` contestants, and it includes the pool leader when you are not already adjacent (`role` `leader`). `tiebreakRule` is `points_desc_games_played_asc_participant_id`; `gamesPlayed` is the tiebreak value (fewer games rank higher). Ranks stay unique when points are equal. Skater lines are `1G 1A`. Goalie lines are the decision, saves, goals against, and save percentage.
- `GET /pools/{poolId}/compare?participantIds=` — two to six rosters, shared players, and players only one roster has.
- `GET /pools/{poolId}/schedule` — games per roster per NHL day, at most 14 days. Counts come from the NHL schedule, including days that are not in the database yet.

`playersRemaining` counts skaters who are still live, in intermission, or yet to start, and it also counts each rostered team entry in those same states. The team entry counts. Null means the skater list is incomplete. That is not zero. `get_standings` `remaining` is that same uncapped set: counting skaters and team picks only. Non-counting bench players are omitted. `playersYetToPlay` includes team picks that have not started. `playersLive` includes each rostered team entry whose game is live or in intermission, on both `get_tonight` and `get_standings`, so live + yet to play equals `playersRemaining` when the skater list is complete. `score` is null until a score exists; a pre-game matchup is not stored in `score`. Score and clock come from one NHL scoreboard snapshot keyed by the dashboard `lastUpdated`. `get_tonight`, `get_roster`, and `get_standings` that report the same `lastUpdated` return the same clocks and scores. A clock is a period and time such as `2nd 12:04`, `FINAL`, `{period} INT` during intermission, or null. It is never a bare period number, and it is never an intermission countdown shown as a period clock. `get_tonight` and `get_standings` wait for a newer dashboard snapshot when the cached one is stale during a live slate, so `lastUpdated` can catch the roster. `isStale` stays true when that wait ends and the snapshot is still old, or when a recompute is pending. A finished slate whose points are current can stay fresh. `rivals` always includes rank 1 when you are not already the adjacent seat above. That context row has `role` `leader`.

Lead-change `fromRank` and `toRank` are the current standings rank and `rankChange` (`fromRank = rank + rankChange`). A climb with `rankChange` 0 is not listed. `at` is the first scoring-play time that reached `toRank` when that feed reproduces the standings. The NHL play feed has a game clock, not a wall clock, so the time adds the period and a standard intermission onto the scheduled start. When the feed does not add up, `at` is that roster’s earliest known scoring play. A later play does not move `at` for the same climb. An earlier play can. The dashboard `lastUpdated` is used only when no play time exists. A different `rankChange` is a different climb and can have a different `at`.

Example `get_tonight` (shape, not a live pool):

```json
{
  "nhlDay": "2026-10-11",
  "lastUpdated": "2026-10-11T23:10:00Z",
  "isStale": false,
  "you": {
    "displayName": "Antoine",
    "rank": 3,
    "tonightPoints": 8,
    "totalPoints": 125,
    "gapToFirst": 2,
    "gapToNext": 1,
    "playersRemaining": 2,
    "upsideRemaining": 9,
    "remaining": [
      { "name": "Nick Suzuki", "state": "live", "startsAt": "2026-10-11T19:00:00-04:00", "score": "MTL 2-1 TOR", "clock": "2nd 12:04" },
      { "name": "Connor McDavid", "state": "scheduled", "startsAt": "2026-10-11T21:00:00-04:00", "score": null, "clock": null }
    ]
  }
}
```

Machine-readable contract: [/api/agent/v1/openapi.json](https://ai-hockey.com/api/agent/v1/openapi.json).

## 4. MCP

Remote MCP endpoint (OAuth, streamable HTTP):

```text
https://ai-hockey.com/mcp
```

A call without a token returns `401` and `WWW-Authenticate` with `resource_metadata` pointing at `/.well-known/oauth-protected-resource`. The client registers at `/oauth/register`, then signs in at `/oauth/authorize`.

MCP POST requests require `Content-Type: application/json` and `Accept: application/json, text/event-stream`. The SDK negotiates the protocol version during initialization. Successful results include both `structuredContent` and a JSON text `content` block.

Both MCP endpoints share one catalog. Tools are listed only when authorized; there are no compatibility aliases.

| Tool | Purpose |
|---|---|
| `list_pools` | Unlocked seats and permissions, returned as `pools` |
| `get_standings` | Pool ranks, totals and gaps; `includeRemaining=true` adds remaining-player detail |
| `get_roster` | Required `view`: `season` for recent/season points, injuries and categories; `live` for scores, clocks and stat lines |
| `get_tonight` | Pool race: rank, gaps, remaining players, rival contributors and comeback upside |
| `get_rival_compare` | Compare 2–6 rosters, including shared and unique picks |
| `get_schedule` | Games per roster per NHL day, at most 14 days |
| `get_digest` | Required `period`: `day` or `week`, ending on optional `endNhlDay` (default last completed day) |
| `get_insights` | Statistical season records and highlights; empty while a draft is not COMPLETED |
| `get_scoring_rules` | Pool points per stat (goal, assist, win, shutout, …) by scoring category |
| `get_draft_state` | Turn, version, composition rules and recent picks |
| `search_draft_candidates` | Undrafted players/teams; optional `type`, `q`, `limit` (max 50) |
| `get_draft_board` | Snake order and paginated active pick history; pass `stateVersion` to detect changes between pages |
| `get_draft_queue` | Your private paginated targets and avoid list (`avoided=true`), notes and availability; full `itemIds` list supports reordering |
| `update_draft_queue` | ASSIST/FULL plus `draft:queue`; typed `mutation.operation=add/remove/reorder/note/clear/replace`; optional `version` on every operation |
| `get_player_projections` | Top projected players; optional `limit` (max 50) |
| `make_draft_pick` | FULL seat, write scope and user approval required |

`get_roster` defaults to your own seat; `participantId` selects a visible rival. Live view accepts `nhlDay` (default today) and `limit` (default 40, max 80). Season view returns season and recent totals. Hidden box picks remain private in both views.

`get_digest` day mode returns points, scorers and injuries. Week mode returns seven NHL days of points, best days and rank changes. AI summaries and draft suggestions are webapp-only, including for personal-token clients.

Successful MCP calls return the same JSON object as `structuredContent` and as `content: [{ type: "text", text: "<json>" }]`. Clients that only render text still see the payload. Errors use `isError=true` and text content. Output contracts are available at [/api/agent/mcp/schemas](https://ai-hockey.com/api/agent/mcp/schemas) on demand.

Standings, season rosters and recaps default to compact statistical detail; use `detail=full` for additional fields. Standings only includes remaining-player names when `includeRemaining=true`. Digest `you` contains your own row; paged `rows` contains the other members. Full weekly recaps include daily point arrays. No digest mode includes AI text.

`list_pools`, `get_standings`, `get_digest`, `get_schedule` and `get_player_projections` accept `offset` and `limit` (max 50). Defaults are 20, or 15 for projections. Collections use deterministic ordering. Follow `nextOffset` until null; `total` counts the paged collection. Schedule pages contain seat identities once in `seats`, with each day’s `games` referring to participant ids. Responses are limited to 128 KiB; request smaller pages/ranges if needed.

Tool inputs validate dates as `YYYY-MM-DD` and enforce advertised numeric bounds. `seatId` always identifies your authorized seat; `participantId` on a roster tool identifies the roster to view.

`POST /api/agent/mcp` remains a script fallback that takes a personal `aih_` token. Do not use it from a chat agent.

Read every page of `get_draft_queue` before recommending picks. Exclude items with `avoided=true`, including from projection recommendations. Lists belong to the authenticated account and linked seat.

`update_draft_queue` accepts `avoided` on an `add` mutation: `{"operation":"add","kind":"player","entityId":"…","avoided":true}` avoids a player; false moves them to targets. Moving preserves the note. Add a reason with `{"operation":"note","itemId":"…","note":"Injury risk","version":4}`. Replace accepts optional `avoided` per item and otherwise preserves retained preferences; clear removes both lists. Both lists share the 500-item limit and queue-write permissions.

Avoided choices are excluded from the account’s built-in AI suggestions and rejected for agent picks through MCP or REST. Ask the user before removing an avoidance preference to make a pick. Manual browser picks remain possible.

## 5. Draft picks

`GET /pools` includes `canMutate`. That flag is true only when the seat unlock is **FULL**, the token includes `draft:pick`, the pool is on the token allowlist when one is set, and the pool is not archived or hosting-locked. A READ seat is always `canMutate: false`, even when pool hosting itself is mutable.

`make_draft_pick` is omitted from the tool list unless the connection has `draft:pick` and a FULL seat. `POST …/draft/picks` enforces the same rule and returns 403 (`insufficient_scope` or `unlock_level_insufficient`) when it fails. An archived or hosting-locked pool returns 409 `pool_read_only`.

`draft:queue` is a separate, opt-in permission for ASSIST and FULL seats to manage their own private queue and notes. It never authorizes picks and is not a default scope. OAuth clients must request `draft:queue` and obtain separate per-seat queue consent. Existing connections need fresh consent; refresh tokens cannot add permission.

A pick also requires:

- `"confirm": true`,
- `observedTurn` matches the live turn from `get_draft_state` (`currentRound`, `currentPick`, `stateVersion`),
- that seat is the one on the clock.

The agent must ask you before it picks. A token cannot pick on someone else's turn, even if you are the commissioner.

## 6. What the agent cannot do

- See pools you have not unlocked, or pools whose hosting is locked.
- See another member's box picks while the pool hides them.
- Use staff or cron credentials. Those are not this API.

### Draft preparation, queues, and safe retries

MCP v3 has 16 tools total. `search_draft_candidates` works before a Draft row exists. Use `type=player|team`, optional `q`, `position=C|L|R|D|G`, `scoringCategoryId`, `availability=all|undrafted|eligible`, `sort=projection|lastSeasonPoints|name` (default `projection`, falling back to last-season points), and `offset`/`limit` (default 20, max 50). Historical stats carry season IDs and an availability flag. These responses contain no premium projections; `get_player_projections` returns data only with the same pool-and-season access the app requires.

`get_draft_state` includes the clock, `composition` with `totalPicksPerParticipant` computed from the stored total or the sum of composition-rule counts, strict category order, current/effective maximum category counts, and up to six upcoming own pick numbers. Draft pick `pickType` is lowercase `player` or `team` (the same convention as `make_draft_pick`; `PLAYER`/`TEAM` are also accepted on pick input). Clock duration fields are milliseconds except `pickTimeLimitSeconds`; `serverTime` is the reference time. `remainingMs` reaching 0 does not auto-pick or pause the draft — the clock is informational. Use `remaining` for total roster slots. `isYourTurn` identifies the seat on the clock; paused drafts still reject picks. `get_draft_board` returns stable pick/entity/category IDs and resolved participant names. Restart board pagination after `stale_turn`.

Queue examples (MCP arguments):

```json
{"poolId":"pool-id","mutation":{"operation":"add","kind":"player","entityId":"player-id"}}
```

```json
{"poolId":"pool-id","mutation":{"operation":"note","itemId":"queue-item-id","note":"Check injury update","version":3}}
```

`remove` requires `itemId`. `reorder` requires every queue item ID exactly once in `itemIds`. `clear` empties the queue. `replace` sets the full ordered list as `items: [{ kind, entityId }, …]` (max 500) in one version increment. Optional `version` is accepted on add, remove, reorder, note, clear, and replace; when it is sent it must match the current queue version. Mutations return the first queue page and new version; GET subsequent pages when needed. A `queue_conflict` requires a reload before retrying. Queue states include `available`, `taken`, `mine`, `inactive`, and `noFit`; entries remain saved when selected by someone else. A commissioner cannot access your private notes/order through commissioner authority.

For REST, GET `/pools/{poolId}/draft/board`, GET `/pools/{poolId}/draft/candidates`, and GET/PATCH `/pools/{poolId}/draft/queue` provide equivalent operations. Queue PATCH takes the mutation object directly. All routes accept `seatId` to disambiguate your own seats.

Before a pick, obtain explicit user approval and read fresh state. Send `draftId`, a unique `requestId`, `pickId`, `pickType` (`player` or `team`; `PLAYER`/`TEAM` also accepted), the observed turn, and `confirm: true`. `scoringCategoryId` may be omitted when exactly one open eligible category remains for that pick; otherwise the error lists the remaining category ids and names. If the response is lost, retry the exact payload and same `requestId`; the original committed result is returned without a second pick, even after completion. A changed payload under that ID returns `idempotency_conflict`. A draft reset deletes receipts for the reused `draftId`, so a pre-reset `requestId` starts a new pick. After success, refresh state before the next pick, including back-to-back snake picks.

Poll state every 5–10 seconds while actively drafting; back off when idle or paused, and share the 60 requests/minute budget across all tools. Honor `retryAfterSeconds` on rate-limit errors. MCP does not wake a stopped agent. Automatic picks and commissioner mutations are not exposed.

Adding an existing entity without `avoided` preserves its current list. Moving between lists requires explicitly setting `avoided`; send the observed `version` to detect concurrent changes.
