A Model Context Protocol server for chess games using Stockfish
Project description
Chess MCP Server
A Model Context Protocol (MCP) server that provides a chess-playing environment backed by the Stockfish engine. Designed for use with LLM clients (like Claude Desktop) to ensure all chess moves are legal and engine-calculated.
Features
- Legal Move Validation: All moves are validated against chess rules
- Stockfish Integration: Uses the Stockfish chess engine for AI moves
- MCP Protocol: Communicates via JSON-RPC over stdio
- In-Memory Game State: Maintains multiple concurrent games
Installation
pip install chess-mcp
You'll also need to install Stockfish:
- Windows: Download from Stockfish website
- macOS:
brew install stockfish - Linux:
sudo apt install stockfish(or equivalent)
Usage
-
Set the
STOCKFISH_PATHenvironment variable to the path of your Stockfish executable:export STOCKFISH_PATH=/path/to/stockfish
-
Run the server:
python -m chess_mcp
MCP Tools
new_game()
Starts a new chess game from the standard initial position.
Returns:
game_id: Unique identifier for the gamefen: Current position in FEN notationlegal_moves: List of all legal moves in UCI format
make_move(game_id, move_uci)
Applies a human move to the game. The move must be in UCI format (e.g., "e2e4").
Parameters:
game_id: Identifier of the active gamemove_uci: Move in UCI format
Returns:
ok: Whether the move was legal and appliedfen: Updated board position (if move was legal)legal_moves: Updated list of legal moves
engine_move(game_id, depth=14)
Asks Stockfish to calculate and play one move for the side to move.
Parameters:
game_id: Identifier of the active gamedepth: Search depth for Stockfish (higher = stronger but slower)
Returns:
engine_move: The move played by Stockfish in UCI formatfen: Updated board position after the movelegal_moves: Updated list of legal moves
Development
To set up for development:
git clone https://github.com/yourusername/chess-mcp.git
cd chess-mcp
pip install -e .
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chess_mcp-0.1.4.tar.gz.
File metadata
- Download URL: chess_mcp-0.1.4.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24af659a5032888a355022c96578b834f276e69b79d1578a9c092d33023f74c9
|
|
| MD5 |
faafc2e32793d540491049c37d9c70b7
|
|
| BLAKE2b-256 |
5623f4395a38bb91377113cbc63a9a7c5e02181b69bd56fcbcfeda03b16a9efb
|
File details
Details for the file chess_mcp-0.1.4-py3-none-any.whl.
File metadata
- Download URL: chess_mcp-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28de31ae06a2786dc34a3833c63c2405b1019ad847a4f22f181a4723cef75de6
|
|
| MD5 |
affea6ae3eb9472be199764e0a210462
|
|
| BLAKE2b-256 |
b7e948910cb5c3e2e2b3b49aecc8be2946e892aba2fff79c0194be1defd8e093
|