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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.