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.1.tar.gz (34.8 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.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for chess_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8cdc167fc09e8e335eb34602a617044c0b97f16dec6447d1b7041d918f4dee5b
MD5 21bb887db226149da80de1004e8f271e
BLAKE2b-256 d66994af2c690c9fea5c0cb3bc7267d7de4f6c896f226c39b7719c02700b21f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chess_mcp-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71496818c0a63f28d1307e81ae4a4aa2eeabe8ccf6abc8440cd5697646630a09
MD5 54435886801a5637ba0ff58e3dc19db7
BLAKE2b-256 082f692fc041bbe8ca86c1fdd791f4ba200e72aab5b3137bc303f1674a1ccc6c

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