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.3.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.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chess_mcp-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4113bfb8c9ba12e2a8da0eda5d24ad2087e0ab6075e85205a74e8b4227f69c0e
MD5 5f3d42ffed9d77d545d6f07f05bde1d2
BLAKE2b-256 d27d403723e26edc747b2bf516da9bb5ebb4156480456b747bde267ed224c490

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chess_mcp-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ac2a2400e37d80980d450b6a33229a997dfa5e2228f6d79cb62a3fa0a81cf50a
MD5 3ae9acfc1a178771c5ccfe15e7c5881b
BLAKE2b-256 6f1d36e0135b69f04fe6a0398f4a77584f7c097c3ca70069bcb409e7ef7f8df7

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