llm-chess-mcp
llm-chess-mcp
LLMがプレイ、分析、強さの調整を、すべての判断をエンジンに委ねることなく行えるMCPチェスランタイムです。
単一の最善手を返すのではなく、客観的な強さ(Stockfish)、人間の手の可能性(Maia3)、実際の対局統計(Lichess)を公開し、LLMがどのようにプレイしたいかを選択できるようにします。LLMが戦略と判断を行い、MCPサーバーがすべての計算を処理します。
エンジン
エンジン | 役割 | ランタイム |
Stockfish 18 (WASM) | 客観的な評価、最善手、multipv | プロセス内 (npm |
Maia3 5M (ONNX) | Eloに基づく人間らしい手の確率 | プロセス内 ( |
Lichess explorer | 実際の人間の対局統計 | HTTP (トークンが必要) |
すべてはNodeプロセス内で実行されます。デプロイ時に外部エンジンプロセスやPythonランタイムは不要です。公開パッケージにはMaia3 5Mモデルが同梱されています。他のエクスポートバリアントは、ONNXファイルが別途提供されない限り、ランタイムオプションにはなりません。
Related MCP server: Chess MCP
インストール
Node.js 20以降が必要です。
インストール不要 — npxで直接実行できます:
npx -y llm-chess-mcpMaia3モデルはすでに同梱されているため、Python、torch、エンジンバイナリをインストールする必要はありません。npxは初回実行時にパッケージを取得し、キャッシュします。
代わりに永続的にインストールする場合:
npm install -g llm-chess-mcpソースからビルド
pnpm install
pnpm build
pnpm testpnpm test:unitはユニットスイートを実行します。pnpm test:e2eは最初にビルドし、その後MCPトランスポートテストを実行します。pnpm checkは完全なローカルゲートを実行します。公開前にpnpm release:checkを使用してください。
メンテナー
アーキテクチャはランタイムとサービスの境界を説明しています。
ローカル品質コマンド:
pnpm typecheck
pnpm test:coverage
pnpm contract:check
pnpm check
pnpm test:packagepnpm test:stressは短い実エンジン並行性チェックを実行します。pnpm test:liveはLICHESS_TOKENが設定されている場合のみLichessにクエリを実行します。それ以外の場合はネットワークリクエストを行わずにスキップします。
Maia3をONNXにエクスポート(ビルド時のみ)
このステップではPython + PyTorchが一度だけ必要です。Maia3チェックポイントをダウンロードし、再実装をオリジナルに対して検証し、models/maia3-5m.onnxをエクスポートします。
uv venv .venv-maia3 --python 3.13
uv pip install --python .venv-maia3/bin/python -r scripts/requirements.txt
uv pip install --python .venv-maia3/bin/python "maia3 @ git+https://github.com/CSSLab/maia3.git@1e13597c42d4858b7cfd7cfdae01e297263364b2"
pnpm export:maia3 # -> models/maia3-5m.onnx結果の.onnxはコミット/バンドルされます。エンドユーザーがPythonやtorchを必要とすることはありません。
Lichessトークン(オプション)
オープニングエクスプローラーは現在認証が必要です。https://lichess.org/account/oauth/token/create で個人アクセストークンを生成し、.envに設定してください:
cp .env.example .env
# set LICHESS_TOKEN=...トークンがない場合、opening_explorerは無効通知を返します。他のすべてのツールは動作します。
エクスプローラーのフィルターは厳格です。スピードはultraBullet、bullet、blitz、rapid、classical、correspondenceです。レーティングバケットは0、1000、1200、1400、1600、1800、2000、2200、2500です。mastersはどちらのフィルターも受け付けません。無効なフィルターはローカルで失敗します。一時的な障害(ネットワーク、タイムアウト、429、5xx)は12秒の総予算内で1回再試行されます。無効なリクエストやその他の4xx応答は再試行されません。
MCPクライアントでの設定
opencode
opencode.json(プロジェクト)または~/.config/opencode/opencode.json(グローバル)に追加:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"llm-chess-mcp": {
"type": "local",
"command": ["npx", "-y", "llm-chess-mcp"],
"enabled": true,
"environment": {
"LICHESS_TOKEN": "your-token"
}
}
}
}Claude Code
.mcp.json(プロジェクト)または~/.claude.json(グローバル)に追加するか、以下を実行:
claude mcp add llm-chess-mcp -- npx -y llm-chess-mcp{
"mcpServers": {
"llm-chess-mcp": {
"command": "npx",
"args": ["-y", "llm-chess-mcp"],
"env": {
"LICHESS_TOKEN": "your-token"
}
}
}
}Codex CLI
~/.codex/config.tomlに追加:
[mcp_servers.llm-chess-mcp]
command = "npx"
args = ["-y", "llm-chess-mcp"]
[mcp_servers.llm-chess-mcp.env]
LICHESS_TOKEN = "your-token"またはCLI経由:
codex mcp add llm-chess-mcp --command npx --args -y llm-chess-mcp --env LICHESS_TOKEN=your-tokenツール
ツール | 説明 |
| ゲームを作成(オプションでFENから)、 |
| ゲームを削除し、セッションを解放 |
| 権威ある状態: FEN、手番、リビジョン、チェック/メイト/ドロー フラグ、履歴、最後の手、キャスリング(オプションでASCII) |
| 手をプレイ(SANまたはUCI)— 唯一の変更ツール、古い位置ガード付き |
| メタデータ付きのすべての合法手 |
| ゲームをPGNとしてエクスポート |
| PGNを新しいゲームにインポート |
| Stockfish multipvライン(cp/mate/WDL + PV)、 |
| ターゲットEloでのMaia3人間の手の確率 |
| 1つ以上の手をスコアリング + cpLoss + 分類 |
| 主要ツール: 統合候補(客観的 + 人間的 + オープニング) |
| 利便性レイヤー: 戦略的意図に基づいてランク付けされた候補 |
| Lichessの人間の対局統計 |
結果形式
structuredContentが正規の成功結果です。ハンドラーレベルの失敗はisErrorを設定し、structuredContent.errorを提供します。入力スキーマの失敗はハンドラーの前にMCP SDKによって生成され、structuredContentなしの標準のisErrorテキスト結果を使用します。それ以外の場合、contentは短い人間可読の要約のみであり、データとして解析してはなりません。
スコアの規約
Stockfishのスコアは手番側の視点です。正のcp = 手番側が有利。
mate N= 手番側がN手でメイト。wdlは手番側の[勝ち、引き分け、負け]をパーミルで表します。move_candidatesはmoverCp(動かす側の視点 — 手を選ぶプレイヤーにとって高いほど良い)とwhiteCp(固定の白の視点)を提供するため、符号が反転することはありません。move_evaluateは動かす側の視点からスコアを報告し、さらにcpLoss(最善手に対して失ったセンチポーン)と分類を提供します:best / excellent / good / inaccuracy / mistake / blunder。maia3Probは人間らしさであり、手の質ではありません。高い確率の手が客観的に悪い場合もあります。
候補構造
move_candidatesは各候補を3つの独立した側面で返します:
{
"uci": "g1f3",
"san": "Nf3",
"objective": { "rank": 1, "moverCp": 55, "whiteCp": 55, "cpLoss": 0, "moverMate": null, "wdl": [153, 844, 3] },
"human": { "maia3Prob": 0.62, "selfElo": 1500, "opponentElo": 1500 },
"opening": { "status": "available", "games": 18421, "frequency": 0.31 }
}objective— Stockfish: エンジンの強さ。人間らしさと混同されることはありません。moverCpは動かす側の視点(選択者にとって高いほど良い)。human— ターゲットEloでのMaia3条件付き確率。opening— Lichessの経験的频率(Maia3とは異なるシグナル)。
opening.statusはavailable、no_data(APIはOKだがこの局面にゲームがない)、unavailable(タイムアウト/429/401)、またはdisabled(トークンなし)です。Stockfish + Maia3の結果は常に返されます。
move_candidatesはまたmoveSensitivityを返し、トップエンジンライン間で評価がどれだけ急激に変化するかを説明します:
{ "moveSensitivity": { "level": "high", "topMoveSpreadCp": 245 } }levelはlow(<80cpスプレッド)、medium(80–200cp)、high(≥200cp)です。感度が高いということは、妥当な代替案の選択が評価を実質的に変える可能性があることを意味します — 手を緩めるか正確にプレイするかを決定するのに役立ちます。
分析レベル
Stockfishツールは生のUCIノブの代わりにanalysis_levelプリセットを受け入れます:
レベル | 深さ | MultiPV |
| 8 | 5 |
| 15 | 8 |
| 22 | 10 |
明示的なdepth/multipvオーバーライドは上級者向けに引き続き利用可能です。
古い位置ガード
すべての状態読み取りはrevisionを返します。game_play_moveは**expected_revisionを必須**とします。最後の読み取り以降にゲームが進行している場合、手は拒否されます:
{ "error": { "code": "STALE_POSITION", "message": "position changed: expected revision 2, current 3" } }ランタイム制限
最大1,000のゲームセッションが保持され、アイドルセッションは1時間後に期限切れになります。
move_evaluateは1回の呼び出しで最大10手を受け入れます。インポートされたPGNは1 MiBと4,096プライに制限されます。
Stockfishは最大32のアクティブまたはキューされた分析を受け入れます。
意図
move_candidates_by_intentは選択された意図に基づいて候補をランク付けします。これはmove_candidatesの利便性レイヤーです。以下の固定しきい値はヒューリスティックなデフォルトであり、真実の源ではありません:
意図 | 意味 |
| 最強のエンジン手 |
| エンジン的に強いが人間的に妥当 |
| ターゲットEloで最も人間に典型的 |
| 強さと人間らしさのブレンド |
| 期待される結果を変えずに利点を控えめに減らす人間的に妥当な手 |
| 相手のチャンスを実質的に改善する人間的に妥当な不正確さ |
このツールは候補をランク付けしますが、手を選択しません。返されたシグナルと会話の文脈を使用して最終決定を行ってください — ユーザーのスキルを機械的に意図にマッピングしないでください。
例のフロー
通常のプレイループは3つの呼び出しです:
create_game→game_idmove_candidates→ 手を選ぶgame_play_move(expected_revision付き)→ コミット
必要な場合にのみ深く進んでください:
position_analyze— 客観的な最善ラインhuman_move_distribution— 特定のEloの人間がプレイする手opening_explorer— 実際の対局統計move_evaluate— 特定の手をスコアリング(または複数を比較)
Maia3 ONNX検証
エクスポートされたONNXモデルは、固定位置とEloペアにわたってアップストリームのMaia3実装に対して回帰テストされます:
.venv-maia3/bin/python scripts/verify_maia3.py --model 5mトップ1/トップkの手の一致と最大確率誤差をチェックし、エクスポート/ランタイムの回帰を検出します。同梱のmaia3-5m.onnxは100%のトップ1およびトップ5一致、最大確率誤差<1e-4で合格します。
パッケージ検証
パッケージアーティファクトはローカルで検証されます。このプロジェクトには意図的にホストされたCIワークフローはありません。
pnpm checkを実行して決定論的なオフラインゲートを行います。pnpm test:packageを使用してプロジェクトをパックし、クリーンな一時ディレクトリにtarballをインストールし、インストールされたllm-chess-mcpバイナリを実際のStockfishとMaiaランタイムに対して実行します。pnpm release:checkは両方のチェックに加えて、本番依存関係の監査とパッケージマニフェストのドライランを実行します。
ライセンスと帰属
このプロジェクトはAGPL-3.0の下でライセンスされています(LICENSEを参照)。
サードパーティのコンポーネントをバンドルおよび依存しています:
コンポーネント | ライセンス | ソース |
Maia3 (Chessformer) | AGPL-3.0 | UofT CSSLab — Monroe ら、Chessformer: チェスモデリングのための統一アーキテクチャ (ICLR 2026) |
Stockfish (npm の | GPL-3.0 | Stockfish 開発者 |
MIT | Microsoft | |
BSD-2-Clause | Jeff Hlywa |
同梱の Maia3 モデル (models/maia3-5m.onnx) は、UofTCSSLab/Maia3-5M の b6559de2398d7140b985f28fd2c19fb5e47ddabe を派生しています。ONNXエクスポートはビルド時のステップ (scripts/export_maia3.py) であり、ランタイムが Maia3 の Python コードを実行することはありません。
Available Tools
13 toolscreate_gameCreate Chess GameA
Create a new chess game and return its game_id. The server is the authoritative source of board state — never track the board yourself. Optionally pass a FEN to start from a custom position.
Inputs: fen. Returns: game_id, revision
delete_gameDelete Chess GameCDestructiveIdempotent
Delete a game and free its session.
Inputs: game_id (required). Returns: deleted, game_id
game_import_pgnImport Chess PGNA
Import a PGN into a new game. Returns a new game_id with the position after all PGN moves. Rejects malformed or illegal PGN.
Inputs: pgn (required). Returns: fen, turn, isDraw, game_id, +12 more
game_legal_movesList Legal Chess MovesARead-onlyIdempotent
List all legal moves in the current position (SAN, UCI, piece, capture, promotion).
Inputs: game_id (required). Returns: count, moves, game_id, revision
game_pgnExport Chess PGNBRead-onlyIdempotent
Export the current game as PGN.
Inputs: game_id (required). Returns: pgn, game_id, revision
game_play_movePlay Chess MoveADestructive
Play a move (SAN like 'e4' or UCI like 'e2e4') and return the resulting state. This is the ONLY tool that mutates the game. expected_revision is required: pass the revision from your most recent game_state/move_candidates read. If the game has advanced since then, the move is rejected with STALE_POSITION.
Inputs: move (required), game_id (required), expected_revision (required). Returns: fen, move, turn, isDraw, +13 more
game_stateGet Chess Game StateARead-onlyIdempotent
Return the authoritative state of a game: FEN, turn, revision, check/mate/draw flags, move history, last move, castling rights. Use this instead of remembering the board. Set include_ascii=true to also get a board diagram.
Inputs: game_id (required), include_ascii. Returns: fen, turn, board, isDraw, +13 more
human_move_distributionEstimate Human Chess MovesARead-onlyIdempotent
Return the Maia3 human-like move probability distribution for the current position, conditioned on a target Elo. Higher probability = more human-typical at that rating. This is NOT move quality — a high-probability move can still be objectively bad.
Inputs: game_id (required), elo, top_n, oppo_elo. Returns: elo, moves, game_id, oppo_elo, +1 more
move_candidatesGenerate Chess Move CandidatesARead-onlyIdempotent
The primary move-selection tool. Combine Stockfish objective evaluation (moverCp, whiteCp, cpLoss, mate, WDL), Maia3 human probability, and Lichess real-game statistics into a unified candidate list. moverCp is from the mover's perspective: higher = better for the player choosing the move. Use this before choosing a move; the final choice is yours.
Inputs: game_id (required), elo, sf_depth, lichess_db, +5 more. Returns: elo, fen, turn, game_id, +4 more
move_candidates_by_intentRank Chess Moves by IntentARead-onlyIdempotent
Convenience layer over move_candidates: rank candidates for a strategic intent. This tool RANKS candidates but does NOT choose a move — use the returned signals and conversation context to make the final decision. Do not map user skill mechanically to an intent. intents: best (strongest engine move), strong (engine-strong but human-plausible), natural (most human-typical), balanced (blend of strength and human-likeness), ease_off (human-plausible moves that modestly reduce advantage without changing the expected result), give_chance (human-plausible inaccuracies that meaningfully improve the opponent's chances).
Inputs: intent (required), game_id (required), elo, sf_depth, +6 more. Returns: elo, fen, turn, intent, +5 more
move_evaluateEvaluate Chess MovesARead-onlyIdempotent
Evaluate one or more moves with Stockfish without mutating the game. Pass a single move string or an array of moves to compare. Returns, for each move, the score after the move (from the mover's perspective), cpLoss vs the best move, and a classification (best/excellent/good/inaccuracy/mistake/blunder).
Inputs: move (required), game_id (required), depth. Returns: game_id, results, revision
opening_explorerQuery Lichess Opening ExplorerBRead-onlyIdempotent
Query the Lichess opening explorer for real human game statistics in the current position (requires LICHESS_TOKEN).
Inputs: game_id (required), db, speeds, ratings. Returns: db, black, draws, moves, +4 more
position_analyzeAnalyze Chess PositionARead-onlyIdempotent
Run Stockfish on the current position and return the top engine lines (multipv). Scores are from the side-to-move perspective: positive cp = side to move is better; mate N = side to move mates in N. wdl is [win, draw, loss] in permille for the side to move. Use analysis_level (fast/normal/deep) or explicit depth/multipv. Does NOT mutate the game.
Inputs: game_id (required), depth, multipv, analysis_level. Returns: fen, turn, lines, game_id, +2 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Game lifecycle tools are clearly distinct: create, delete, state, move, legal moves, PGN export/import. The move-analysis tools overlap somewhat—position_analyze, move_evaluate, move_candidates, and move_candidates_by_intent all return evaluation-like signals—but their descriptions clarify different purposes: raw engine lines, per-move comparison, unified candidate selection, and intent-based ranking. An agent could hesitate between these, but they are not truly interchangeable.
Some names follow verb_noun (create_game, delete_game), while others are noun phrases or prefixed differently (game_state, game_pgn, game_import_pgn, position_analyze, opening_explorer). The move_* group is predictable, but the overall naming is a mix of conventions. Names are still readable and snake_case consistent, so the inconsistency is moderate rather than chaotic.
Thirteen tools is well within the ideal range and appropriate for a chess server that handles game lifecycle, PGN import/export, legal move queries, engine analysis, human-move modeling, and opening statistics. Each tool has a defined role, and the count does not feel bloated or thin.
The surface covers the full lifecycle: create, read state, mutate via play move, legal moves, delete, and PGN import/export. Analysis coverage is also strong: Stockfish lines, move evaluation, human move distributions, unified candidates, intent-based ranking, and opening explorer. There are no obvious dead ends for playing or analyzing a chess game.
Maintenance
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that lets your AI talk to Stockfish. Because apparently we needed to make chess engines even more accessible to our silicon overlords.16MIT
- AlicenseNot gradedqualityDmaintenanceA powerful chess engine and game server built with the Model Context Protocol (MCP). Play chess against AI, analyze positions, and integrate chess functionality into your AI applications.1MIT
- AlicenseAqualityDmaintenanceA hybrid AI chess coach MCP server that uses Stockfish for grounded evaluation and LLM for natural-language coaching, enabling game analysis, weakness diagnosis, and personalized drills from your own games.65MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that exposes Stockfish chess analysis to LLM chat clients, enabling move analysis, game review, and explanation of engine choices.-