> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fantasytier.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP

> Connect AI agents to Fantasy Tier via the hosted Model Context Protocol endpoint.

Fantasy Tier exposes a hosted **Model Context Protocol (MCP)** server so AI agents can read league data and prepare (and optionally submit) Account Abstraction transactions — the same public API path the web app uses.

**Endpoint:** [https://www.fantasytier.com/mcp](https://www.fantasytier.com/mcp)

## Connect

Add the server to your MCP client (Cursor, Claude, and similar). Example config:

```json theme={null}
{
  "mcpServers": {
    "fantasy-tier": {
      "url": "https://www.fantasytier.com/mcp",
      "headers": {
        "X-Fantasy-Tier-Owner-Private-Key": "0xYOUR_AGENT_PRIVATE_KEY"
      }
    }
  }
}
```

* **Omit the header** for reads and prepare-only writes. Sign outside the MCP session, then call `relay`.
* **With the header**, set `autoSubmit: true` on prepare tools and pass an `owner` that matches that key’s address. The server signs and relays in-request (bring-your-own-key — the key is not stored).

<Warning>
  Never commit private keys. Use a dedicated agent wallet with limited funds — not a personal cold wallet.
</Warning>

## Write flow (Account Abstraction)

1. Call a prepare tool (`create_squad`, `commit_squad_changes`, and similar). The response includes a `relayHint` (`intentId`, `userOperation`, `signingContext`).
2. Sign the UserOp with the Safe owner, **or** use BYOK + `autoSubmit: true` when `owner` matches the header key’s address.
3. Call `relay` with the signed UserOp (skipped when `autoSubmit` already relayed).
4. Optionally poll `get_user_operation_receipt`.

Without a signer, prepare tools never sign. `autoSubmit: true` without the BYOK header returns an error telling the agent to sign outside and call `relay`.

## Tools

### Reads

| Tool                    | Notes                                                            |
| ----------------------- | ---------------------------------------------------------------- |
| `list_leagues`          | Prefer before inventing addresses; defaults to official leagues  |
| `get_league`            | Rules, budget, and `boostersConfig` when known                   |
| `get_game_weeks`        | Reality / results status                                         |
| `get_game_week_results` | Proofs stripped; `includePlayerStats` opt-in                     |
| `get_leaderboard`       | Overall or per game week; default page size 50                   |
| `list_squads`           | Default page size 50; slim unless `detailed=true`                |
| `get_squad`             | Enriched lineup, boosters, budget, transfer allowance            |
| `get_squad_game_week`   | Formation snapshot for a game week                               |
| `get_squad_transfers`   | Transfer history; optional `gameWeek`                            |
| `get_player_transfers`  | Most transferred in/out for a game week                          |
| `search_players`        | Name search — prefer over the full roster                        |
| `suggest_transfer_outs` | Valid outs for a given `playerIn`                                |
| `suggest_transfer_ins`  | Ranked ins by `form`, `value`, or `fixture`                      |
| `suggest_squad`         | Create-ready starters, backups, and boosters                     |
| `get_players`           | Full roster (large) — prefer `search_players` or `suggest_squad` |
| `get_fixture`           | Calendar or range-only                                           |

<Tip>
  Prefer `suggest_squad` and `search_players` over `get_players` to keep payloads small for agents.
</Tip>

### Writes / Account Abstraction

| Tool                         | Notes                                               |
| ---------------------------- | --------------------------------------------------- |
| `validate_squad`             | Dry-run composition check (no UserOp)               |
| `create_squad`               | Prepare create; optional `autoSubmit`               |
| `commit_squad_changes`       | Prepare transfers / boosters; optional `autoSubmit` |
| `join_league`                | Prepare; optional `autoSubmit`                      |
| `abandon_league`             | Prepare; optional `autoSubmit`                      |
| `claim_game_week_prize`      | Prepare (needs merkle proof); optional `autoSubmit` |
| `set_squad_name`             | Prepare; optional `autoSubmit`                      |
| `buy_credits`                | Prepare; optional `autoSubmit`                      |
| `set_username`               | Prepare; optional `autoSubmit`                      |
| `relay`                      | Submit an already-signed UserOp                     |
| `predict_wallet`             | Predicted Safe address for an owner                 |
| `get_user_operation_receipt` | Bundler receipt after relay                         |

Player refs accept **names** (preferred) or hex ids.

## Example agent flows

### Create a squad

1. `get_league` — sizes, budget, `boostersConfig`
2. `suggest_squad` — optional `strategy` (`form` default)
3. `validate_squad` — optional sanity check
4. `create_squad` — same lineup plus `squadName` / `owner` (and `autoSubmit` if using BYOK)

### Make transfers

1. `get_squad` — lineup, boosters, budget, transfer allowance
2. `suggest_transfer_ins` (or `search_players` + `suggest_transfer_outs`)
3. `commit_squad_changes` with `playerOuts`, `playerIns`, and optional `boosters`

Each prepare with `autoSubmit` pays a bundler gas estimate — multi-step create + transfer loops are slower by design.
