Skip to main content

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

  1. Set the STOCKFISH_PATH environment variable to the path of your Stockfish executable:

    export STOCKFISH_PATH=/path/to/stockfish
    
  2. 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 game
  • fen: Current position in FEN notation
  • legal_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 game
  • move_uci: Move in UCI format

Returns:

  • ok: Whether the move was legal and applied
  • fen: 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 game
  • depth: Search depth for Stockfish (higher = stronger but slower)

Returns:

  • engine_move: The move played by Stockfish in UCI format
  • fen: Updated board position after the move
  • legal_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

chess_mcp-0.1.7.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chess_mcp-0.1.7-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file chess_mcp-0.1.7.tar.gz.

File metadata

  • Download URL: chess_mcp-0.1.7.tar.gz
  • Upload date:
  • Size: 33.1 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

Hashes for chess_mcp-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8a760e2aee0426885f72fa224b752a98eeeff65b23b756c2dbe9fb9766807644
MD5 056fca057daebd7dade325b712a70172
BLAKE2b-256 70aa0b4bc51f8b9dfd2aec82764dde8e9a519499d4161dd9e09e7c60f633a32d

See more details on using hashes here.

File details

Details for the file chess_mcp-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: chess_mcp-0.1.7-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

Hashes for chess_mcp-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7d5195659c1c08157e55521db117fd4cc9e5090fe8702a56382cc293d5ac9a2d
MD5 f413bbb6832149fcd61d6bcbea0dad97
BLAKE2b-256 8f45e2e2deeb750af5b6a007f8cc1b8f8339033d8965c739c68d8cd0f988575f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page