Chess Engine MCP Server
Enables AI assistants to perform professional-grade chess analysis using Stockfish and optionally Leela Chess Zero, including position analysis, full game review, opening lookup, and puzzle generation.
README
Chess Engine MCP Server
A Model Context Protocol (MCP) server providing AI assistants with professional-grade chess analysis using Stockfish (alpha-beta) and optionally Leela Chess Zero / Lc0 (neural network). Both engines share the same tool interface and run side-by-side when Lc0 is configured.
Features
Stockfish tools (always available)
| Tool | Description |
|---|---|
sf_analyse_position |
Analyse any position (FEN → evaluation + best moves + top lines) |
sf_analyse_game |
Full game analysis (PGN → move-by-move eval, accuracy %, error counts) |
sf_lookup_opening |
Search opening database by name or ECO code |
sf_identify_opening |
Identify the opening from moves or PGN |
sf_generate_puzzle |
Generate tactic puzzles from positions |
Lc0 tools (enabled when LC0_WEIGHTS_PATH is set)
| Tool | Description |
|---|---|
lc0_analyse_position |
Analyse a position with the Lc0 neural network |
lc0_analyse_game |
Full game analysis using Lc0 evaluation |
lc0_generate_puzzle |
Generate tactic puzzles using Lc0's evaluation |
Quick Start
Option 1: Docker (recommended)
# Stockfish only
docker build -t chess-mcp-server .
docker run -i chess-mcp-server
# With Lc0 (mount weights file)
docker run -i \
-e LC0_WEIGHTS_PATH=/weights/lc0.pb.gz \
-v /path/to/weights:/weights \
chess-mcp-server
# Or with docker compose
docker compose up --build
Option 2: Local Node.js
Prerequisites: Node.js 22+, Stockfish binary installed.
# Install Stockfish
# macOS: brew install stockfish
# Ubuntu: sudo apt install stockfish
# Windows: download from https://stockfishchess.org/download/
# Install dependencies and build
npm install
npm run build
# Run (Stockfish only)
npm start
# Run with Lc0
LC0_WEIGHTS_PATH=/path/to/lc0.pb.gz npm start
Configuration
Stockfish environment variables
| Variable | Default | Description |
|---|---|---|
STOCKFISH_PATH |
stockfish |
Path to the Stockfish binary |
STOCKFISH_THREADS |
2 |
Number of CPU threads |
STOCKFISH_HASH |
128 |
Hash table size in MB |
Lc0 environment variables
| Variable | Default | Description |
|---|---|---|
LC0_WEIGHTS_PATH |
(unset) | Path to a .pb.gz weights file — required to enable Lc0 |
LC0_PATH |
lc0 |
Path to the Lc0 binary |
LC0_BACKEND |
(auto) | Lc0 backend: cuda, metal, cpu, etc. |
LC0_THREADS |
2 |
Number of CPU threads for Lc0 |
LC0_HASH |
128 |
Hash table size in MB for Lc0 |
Note: The
depthparameter for Lc0 tools is mapped internally to node counts via an exponential table (100 nodes at depth 1 → 1 000 000 nodes at depth 30), since MCTS depth is not comparable to alpha-beta depth.
Claude Desktop Integration
Add to your claude_desktop_config.json:
Docker (Stockfish only)
{
"mcpServers": {
"chess": {
"command": "docker",
"args": ["run", "-i", "--rm", "chess-mcp-server"]
}
}
}
Docker (Stockfish + Lc0)
{
"mcpServers": {
"chess": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "LC0_WEIGHTS_PATH=/weights/lc0.pb.gz",
"-v", "/path/to/weights:/weights",
"chess-mcp-server"
]
}
}
}
Local Node.js
{
"mcpServers": {
"chess": {
"command": "node",
"args": ["/path/to/chess-mcp-server/dist/index.js"],
"env": {
"STOCKFISH_PATH": "stockfish",
"STOCKFISH_THREADS": "2",
"STOCKFISH_HASH": "256",
"LC0_PATH": "lc0",
"LC0_WEIGHTS_PATH": "/path/to/lc0.pb.gz"
}
}
}
}
Usage Examples
Stockfish
"Analyse this position: rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1"
"Review this game: 1. e4 e5 2. Qh5 Nc6 3. Nf3 g6 4. Qh4 Be7 ..."
"What is the Wayward Queen Attack?"
"What opening is 1. e4 e5 2. Nf3 Nc6 3. Bc4?"
"Create a tactic puzzle from this position: [FEN]"
Lc0
"What does the neural network think of this position?"
"Analyse this game with Lc0 and compare with Stockfish: 1. e4 e5 ..."
"Find tactics using Lc0 in this position: [FEN]"
Architecture
src/
├── index.ts # MCP server entry, tool registration (Stockfish + Lc0)
├── types.ts # TypeScript interfaces (UciEngine, UciLine, UciScore, …)
├── constants.ts # Thresholds, defaults, LC0_DEPTH_TO_NODES mapping
├── schemas/
│ └── index.ts # Zod input validation schemas
├── services/
│ ├── engine.ts # BaseUciEngine, StockfishEngine, Lc0Engine
│ ├── chess-utils.ts # chess.js wrapper (PGN/FEN/SAN/openings)
│ └── formatting.ts # Markdown output formatting
└── tools/
├── analyse-position.ts # Single position analysis
├── analyse-game.ts # Full game analysis + accuracy model
├── openings.ts # Opening lookup & identification
└── puzzle.ts # Tactic puzzle generation
Both engines implement the UciEngine interface and are interchangeable at the tool layer — all tool functions accept a UciEngine parameter, so sf_* and lc0_* tools share identical logic with different engine instances.
Development
npm install # Install dependencies
npm run build # Compile TypeScript → dist/
npm test # Run unit tests (Vitest, ~125 tests)
npm run lint # ESLint
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。