Skip to main content
Glama
README.md
# Lichess Bot MCP

A focused, local stdio MCP server for playing standard chess through the official Lichess Bot API. No chess engine, position scoring, opening database, browser automation or automatic decision maker. The client chooses every move.

## Requirements

Node.js 24 LTS, npm, and a dedicated Lichess BOT account. Never convert your personal account: BOT conversion is irreversible. Create a token for the bot with `bot:play`, `challenge:read` and `challenge:write`; store it outside the repository. No token is needed for tests.

```sh
npm ci
npm run verify
npm start
```

The server speaks JSON-RPC over stdin/stdout; launch from an MCP client rather than an interactive terminal. No listener or public port is opened.

## Tools

| Tool                                 | Purpose                                                             |
| ------------------------------------ | ------------------------------------------------------------------- |
| get_profile                          | BOT account and ratings                                             |
| list_online_bots                     | Find bot opponents                                                  |
| list_challenges                      | Incoming/outgoing challenges                                        |
| create_challenge                     | Casual standard challenge                                           |
| accept_challenge / decline_challenge | Handle challenges explicitly                                        |
| get_active_games                     | Discover games                                                      |
| get_game_state                       | FEN, piece locations, threats, clocks, legal moves                  |
| make_move                            | Validate, submit and optionally wait                                |
| preview_move                         | Inspect one candidate and immediate legal replies                   |
| wait_for_turn                        | Bounded wait                                                        |
| resign_game                          | Explicit resignation                                                |
| record_game_result                   | Persist a verified terminal game and optional model metrics locally |
| get_game_history                     | Recent results                                                      |

## Play workflow

1. Verify the dedicated BOT profile (also opens the incoming-event stream).
2. Challenge a consenting opponent or accept a supported challenge. Initial testing is casual only; minimum 10 minutes, recommended 30+20 or longer.
3. Get active games; read the selected game state.
4. Choose a legal UCI move using your own reasoning. Preview risky candidates, submit the chosen move with `expected_ply` copied exactly from the current state (0 for White’s first move, 1 for Black’s; never increment), and use the returned state. Wait separately only when needed. Stop at a terminal status.
5. If a write outcome is uncertain, reconcile with a fresh read. Never blindly repeat a POST. A stale-position error reports both the supplied and current ply; refresh the state before choosing a move again.

See [Hermes configuration](docs/hermes.md) and [operational notes](docs/operations.md).

## Verification

`npm run verify` runs syntax checks, unit tests, mocked HTTP/stream integration and a real local MCP stdio handshake. A live authenticated game requires a BOT token; these tests do not claim to verify live Lichess gameplay.

## Upstream references

- [Lichess API](https://lichess.org/api#tag/Bot)
- [API rate limits](https://lichess.org/page/api-tips)
- [Fair play](https://lichess.org/page/fair-play)
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
- [chess.js](https://github.com/jhlywa/chess.js)

## Chess context (0.2.0)

State tools return compact context by default: FEN, last four UCI moves, piece locations (e.g. Qd2), material balance from your perspective, geometric attackers/defenders of your pieces, legal moves, ply and clock snapshot. Pass `detail: "full"` for ASCII and complete history. Piece values are conventional material counts, not position evaluation.

Use `preview_move` for a **single candidate** before committing a risky move. It reports exact immediate legal opponent captures/checks and geometric attacks after that move, without posting, ranking, engine evaluation or suggesting alternatives. Pinned attackers can appear in geometric maps; use legal replies for actual captures. Never submit a move without checking the current legal list and expected ply. Reassess material and threats before resigning; material alone is not a reason to resign.

`make_move` now waits up to 8 seconds for the opponent after confirmation (set `wait_seconds: 0` for original behavior). If returned state is already your turn, no separate wait call is needed. A confirmed move remains confirmed even if the following state read fails. Default challenge is 30+20; explicit shorter permitted time controls remain unchanged.

Regression fixture: public game https://lichess.org/XORTzX6T — Rxh3 opened Qg5xd2. Preview detects the exact legal capture, with no engine.

## Clock and results (0.3.0)

State and preview responses now include `timing`: estimated own remaining milliseconds, increment, pressure level and advisory `think_budget_seconds` (capped at 20 seconds). The countdown uses monotonic time since the stream sample, subtracting elapsed time only on your own turn after the opening two plies. This is not a server clock or a hard deadline; latency, reconnects and initial clock behavior can make it inaccurate. Never rely on it to guarantee a move will arrive in time.

Call `record_game_result` with a completed game ID and explicit confirmation. The server checks the official export, standard variant, terminal status and BOT participation, then saves one JSON file per game under `~/.local/share/lichess-bot-mcp/results/`. Optional model, provider, reasoning, and tool counts are client-reported; absent values stay null. Existing records are preserved on duplicate calls. No credentials or arbitrary paths are accepted.

The bundled [Hermes skill](skills/lichess/SKILL.md) and [benchmark protocol](skills/lichess/references/benchmark.md) provide the recommended play loop. Install instructions are in [docs/hermes.md](docs/hermes.md).

GitHub releases use Conventional Commits and semantic-release after CI passes. Git tags and GitHub releases are the canonical release versions; the source package/MCP version is maintained with changes. No npm publishing is configured.

TDQS

A3.5/5.0

Scored across 14 tools

Disambiguation5/5

Each tool has a distinct resource-and-action purpose: challenge management, active-game inspection, move preview/submission, waiting, resignation, profile/history, and result recording. The closest pair, get_game_state and preview_move, are clearly separated because preview_move simulates one chosen move while get_game_state reports the current position.

Naming Consistency5/5

All names are snake_case and consistently follow a verb_noun pattern such as list_online_bots, create_challenge, get_game_state, and make_move. There are no mixed conventions or vague standalone verbs.

Tool Count5/5

Fourteen tools is well within the appropriate range and each tool corresponds to a meaningful step in the bot's chess lifecycle. The set is scoped without obvious redundant tools.

Completeness4/5

Core lifecycle coverage is strong: discovery, challenges, active games, board state, move preview, move submission, waiting, resignation, history, and local result recording. Minor gaps remain, such as canceling an outgoing challenge or offering/accepting draws, but agents can work around them for the stated bot-play purpose.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues