Skip to main content
Glama
hoopodds

hoopodds

README.md
# hoopodds

hoopodds is a small local bridge to the hosted
HoopsAPI basketball-odds MCP server. It gives you
the odds picture for basketball in one place: which
competitions have upcoming games, the games in a
competition with each bookmaker's moneyline, handicap
and total, a single game opened up in full with every
period covered, the complete price-change history of
a game so you can follow line movement through to the
closing price, the largest disagreements between
bookmakers on the main lines, and the list of the six
bookmakers covered with the time each was last
collected.

The bridge keeps no odds locally. It answers the tool
list itself, exactly as captured from the live
endpoint, and forwards every tool call upstream,
returning whatever comes back untouched. The whole
surface is read-only market data: there is no way to
place a bet, open an account, or move money through
this package — it republishes odds and nothing else.

## Tools

- `list_competitions` — the competitions that have
  upcoming games with odds, with the number of games
  in each. Takes no arguments. Use it to find the
  exact competition name the other tools expect.
- `list_games` — upcoming games in one competition.
  Required: `competition` (the name, case-insensitive,
  for example "NBA"). Optional: `include_periods`
  (also return halves and quarters; larger response,
  default false). Each game carries every bookmaker's
  main moneyline, handicap (the spread, stated as the
  home team's handicap) and total, in decimal odds,
  full game only unless periods are requested.
- `get_game` — one game by id with every bookmaker's
  main lines for every period. Required: `game_id`.
  Optional: `include_alternate_lines` (also return
  every alternate handicap and total line; larger
  response, default false). Works for finished games
  too, returning their closing odds.
- `get_game_history` — every price change for a game,
  newest first, for line movement and closing odds
  (Data plan). Required: `game_id`. Optional:
  `provider` (restrict to one bookmaker), `market`
  (moneyline, spread, total, team_total_home or
  team_total_away), `period` (ft, h1, h2 or q1–q4)
  and `limit` (1 to 5000, default 100).
- `list_discrepancies` — the biggest cross-bookmaker
  differences on main lines for upcoming games:
  moneyline prices, handicap lines and totals (Pro
  and Data plans). All arguments are optional:
  `competition`, `period` (ft, h1, h2 or q1–q4,
  default ft) and `limit` (1 to 20, default 5).
- `list_providers` — the bookmakers covered and when
  each was last collected. Takes no arguments.

## Configuration

- `HOOPSAPI_MCP_URL` (optional) — override the
  upstream endpoint. Defaults to
  `https://hoopsapi.com/mcp`. (The override hook is
  this rebuild's own labelled reconstruction.)
- `HOOPSAPI_API_KEY` (optional) — when set, every
  upstream request carries an
  `Authorization: Bearer <key>` header with the
  caller's own HoopsAPI key. When it is not set, no
  key header is sent. (The header name is pinned by
  the original's registry record; the record pins no
  package env name, so the env name, the Bearer form
  and the forwarding itself are labelled
  reconstructions — the original surface was captured
  keyless.)

### Forwarding mechanics

On the first tool call the client opens a streamable
HTTP session upstream: a JSON-RPC `initialize`
request (protocolVersion `2025-03-26`, clientInfo
name `hoopodds`), then a
`notifications/initialized` notification, then the
`tools/call` request carrying the caller's arguments
unchanged. When the upstream answers `initialize`
with an `Mcp-Session-Id` header, that value rides on
every later request of the session, which is reused
for the life of the process. Replies may arrive as
plain JSON or as server-sent events; both are read.

Successful upstream results pass through verbatim,
including any `isError` flag the upstream sets.
Failures — a JSON-RPC error, a non-2xx status, an
unreadable response, or a request that cannot be
completed — come back as an `isError` result whose
text starts with `hoopodds error:` (this rendering
is this rebuild's own labelled reconstruction).

## CLI

Each tool is also a subcommand taking one JSON
argument string:

```bash
npx @reneturcios/hoopodds list_competitions '{}'
npx @reneturcios/hoopodds list_games '{"competition":"NBA"}'
npx @reneturcios/hoopodds get_game '{"game_id":12345}'
npx @reneturcios/hoopodds get_game_history '{"game_id":12345,"market":"spread"}'
npx @reneturcios/hoopodds list_discrepancies '{"limit":10}'
npx @reneturcios/hoopodds list_providers '{}'
npx @reneturcios/hoopodds --version
```

Exit codes: `0` on success, `1` on an `isError`
result, `2` on a usage error.

## MCP server

```bash
npx -y @reneturcios/hoopodds mcp
```

MCP client config:

```json
{
  "mcpServers": {
    "hoopodds": {
      "command": "npx",
      "args": ["-y", "@reneturcios/hoopodds", "mcp"]
    }
  }
}
```

## Docker

```bash
docker run -i ghcr.io/cloudcorprecords/hoopodds
docker run --rm ghcr.io/cloudcorprecords/hoopodds --version
```

The container's default command is `mcp`, so the first
form is a stdio MCP server; any other arguments reach
the CLI normally.

## Development

```bash
npm install
npm run build
npm test
npm run dev
```

The test suite runs entirely against a stubbed
JSON-RPC upstream — no live network calls.

## License

MIT — see `LICENSE`.