Skip to main content
Glama

β™ŸοΈ Chess Coach MCP

An MCP server that turns any AI assistant into a chess coach

It fetches your games from Lichess or Chess.com, analyzes every move with Stockfish, and gives the AI the ground truth it needs to explain why you lost, in plain language.

Python MCP Stockfish Lichess Chess.com Tests CI

Built by Deven Kalathiya

The position before the losing move: the played move in red, the engine's move in green

The coach's verdict: "The game was decided by one move: 18. Bf4. It hung the bishop and ignored the pawn on f3. 18. gxf3 was the safe move. Lesson: when a pawn lands next to your king, deal with it before anything else."


πŸ“Œ The problem

Today's option

What's wrong

❌ Chess.com Game Review

Limited free uses per day; the full version is paid

❌ Lichess analysis

Free, but only shows numbers (?? -3.2), never why

❌ Human coach

Explains properly, but expensive and needs scheduling

Engines tell you what was wrong. Coaches tell you why. Only the expensive option explains it in words you can learn from.

Related MCP server: MCP Chess Server

πŸ’‘ The idea

Explaining chess in natural language is exactly what an LLM is good at. What it lacks is ground truth: it cannot calculate variations reliably. So the work is split:

Who

What

🐟 Stockfish

runs locally, auto-downloaded

evaluates every position, finds the best move and line

πŸ”Œ This MCP server

Python, no hosting, no API keys

fetches the games, runs the engine, labels every move, returns clean JSON

πŸ€– The AI client

Claude Desktop, Cursor, Claude Code

reads the JSON and coaches: names the motif, says what to play, gives one lesson

Users add one line to their client's config. No website, no account, no paid API: Lichess, Chess.com and Stockfish are all free.


πŸ” How it flows

flowchart LR
    U([You]) -->|"coach my last game"| C[AI client<br/>Claude Desktop / Cursor]
    C <-->|MCP over stdio| S

    subgraph S[chess-coach-mcp]
        direction TB
        T[Tools<br/>get_recent_games Β· analyze_game<br/>find_blunders Β· get_opening_stats]
        R[Resources<br/>chess://games/… Β· chess://game/…/pgn]
        P[Prompts<br/>coach_my_last_game Β· weekly_review]
        CORE[Analysis core<br/>evaluate β†’ centipawn loss β†’ classify β†’ cache]
        T --> CORE
        R --> CORE
        P --> CORE
    end

    CORE -->|games| L[(Lichess API)]
    CORE -->|archives| CC[(Chess.com API)]
    CORE -->|UCI| SF[Stockfish]
    CORE --> DB[(SQLite cache)]
  1. You pick Coach my last game in the client and type your username.

  2. The AI calls get_recent_games, then analyze_game. You see a progress bar while Stockfish works (about 10 to 40 seconds for a full game).

  3. The server returns every move's evaluation, a label (best / good / inaccuracy / mistake / blunder), the engine's best line, per-player accuracy, and the critical moments with their exact position (FEN).

  4. The AI explains the three biggest mistakes and gives you one lesson. Follow-up questions ("what should I have played instead?") are instant because the report is cached.

πŸ‘‰ Read the complete worked example, start to finish, with the real tool calls and the real coaching answer. Read the idea, flow and UI write-up for the design.


🧰 What the AI gets to use

All three MCP primitives, not just tool calling.

Tools

Tool

Input

Returns

get_recent_games

username, platform (lichess / chesscom), count

game ids, opponent, your result, opening, date

analyze_game

game id or URL, username

per-move evals, labels, best lines, accuracy, critical moments with FEN

find_blunders

game id, username, threshold

only the moves that lost material, worst first

get_opening_stats

username, colour

win / draw / loss per opening, your weakest openings

engine_status

which engine is running and cache statistics

Resources

URI

Content

chess://games/{username}/recent

JSON list of recent games

chess://game/{game_id}/pgn

raw PGN (platform guessed from the id)

Prompts

Prompt

What it does

coach_my_last_game

fetch + analyze your last game, explain the 3 biggest mistakes, one lesson

weekly_review

analyze the last 7 days, find the recurring patterns behind your losses


πŸ”¬ How the analysis works

Centipawn loss

Label

more than 300

blunder

100 to 300

mistake

50 to 100

inaccuracy

less than 50

good / best

  • Every position goes through Stockfish at depth 14, capped at half a second each.

  • Evaluations are clamped to Β±10 pawns, so "winning more slowly" in a crushed position is not a blunder.

  • Suspicious moves are re-checked at depth 18, so shallow false positives disappear.

  • Accuracy uses the Lichess formula. Games and reports are cached in SQLite, keyed by game, depth and engine.

  • If Stockfish cannot be downloaded, the server falls back to Lichess cloud evaluations and says so in the report.


πŸ’¬ Example conversations

You type

What happens

"Coach me through my last game"

Fetches it, analyzes it, explains the 3 worst moves and gives one lesson

"What should I have played on move 18?"

Answers from the cached report, with the engine's line

"Which openings do I lose most with as Black?"

get_opening_stats, grouped by opening family

"Give me a weekly review"

Analyzes every loss from the last 7 days and names the recurring motif

"Show me another game where I hung a piece"

Scans recent games' blunders for the same pattern


πŸ”’ Source code

This repository is a showcase of the project. The source code is kept private. If you'd like a live demo or a walkthrough of the code, feel free to reach out.


🧩 Design decisions

  • The chess core has zero MCP imports. Tools, resources and prompts are thin wrappers over it, so the analysis is testable without an MCP client and reusable from a CLI or a web app.

  • Pluggable engine. Local Stockfish and the Lichess cloud fallback implement the same two-method protocol; tests use a deterministic fake, so the whole MCP surface is tested in-process in under 3 seconds.

  • Ground truth, not opinions. The server never explains anything. It returns numbers, labels and positions; the explaining is left to the model, which is what it is good at.

  • Errors the model can act on. Anticipated failures (unknown user, rate limit, missing engine) reach the AI as readable messages instead of a generic "tool failed".

  • Bounded time. Per-position time caps keep a 90-move game to about a minute instead of several.

πŸ”­ Roadmap

Motif tagging across games (hanging piece, fork, back-rank, time pressure), puzzle suggestions from the Lichess puzzle database matched to your weak motifs, and opening repertoire advice from the Lichess opening explorer.

πŸ› οΈ Tech

Python 3.11+ Β· official mcp SDK 2.x Β· python-chess Β· httpx Β· SQLite Β· Stockfish 19 Β· pytest + ruff Β· GitHub Actions on Linux, Windows and macOS


Available Tools

5 tools
analyze_gameA
Read-only

Run a full engine analysis of one game and classify every move.

Returns evaluation before/after each move, centipawn loss, a label (best/good/inaccuracy/mistake/blunder), the engine's best move and line, per-player accuracy and error counts, and the five most critical moments with their FEN so you can explain why a move was bad. Results are cached, so repeat calls are instant.

Args: game_id: Game id or URL from Lichess or Chess.com (as returned by get_recent_games). platform: "lichess" or "chesscom". Guessed from the id when omitted. username: The player to coach. Required for Chess.com games that were not fetched via get_recent_games; otherwise optional (adds user_color/user_result). depth: Engine search depth (default 14; 18+ is slower but more precise).

Inputs: game_id (required), depth, platform, username. Returns: object

engine_statusA
Read-only

Report which chess engine the server is using (local Stockfish or Lichess cloud fallback), where it lives, and cache statistics. Useful for troubleshooting.

Inputs: no named parameters. Returns: object

find_blundersA
Read-only

Return only the moves that lost at least threshold centipawns, with the position (FEN), the engine's best move and the best line, sorted from worst to least bad.

Cheaper to read than analyze_game when you only need the mistakes.

Args: game_id: Game id or URL from Lichess or Chess.com. platform: "lichess" or "chesscom". Guessed from the id when omitted. username: The player to coach; required for uncached Chess.com games. threshold: Minimum centipawn loss to include (100 = mistakes and blunders). only_user: If true, return only the mistakes made by username.

Inputs: game_id (required), platform, username, only_user, +1 more. Returns: object

get_opening_statsA
Read-only

Win/draw/loss record per opening over a player's recent games.

Helps spot openings the player struggles with. Each row carries the game ids so you can dig into a specific loss with find_blunders.

Args: username: The player's username. platform: "lichess" (default) or "chesscom". color: "white", "black" or "both" (default). count: How many recent games to look at (1-300). group_by_family: Group variations under their opening family (default true).

Inputs: username (required), color, count, platform, +1 more. Returns: object

get_recent_gamesA
Read-only

List a player's most recent games from Lichess or Chess.com.

Returns one entry per game with the game_id (use it with analyze_game / find_blunders), the opponent, the result from the player's point of view, the opening and the date. Games are cached locally so later tools can find them by id.

Args: username: The player's username on the chosen platform. platform: "lichess" (default) or "chesscom". count: How many games to return (1-100).

Inputs: username (required), count, platform. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: fetching games, full game analysis, blunder-only extraction, engine diagnostics, and opening statistics. The overlap between analyze_game and find_blunders is explicitly framed as a cheaper subset, so selection is unambiguous.

    Naming Consistency4/5

    Most tools follow a predictable verb_noun pattern (get_recent_games, analyze_game, find_blunders, get_opening_stats), but engine_status is a noun phrase without a verb. The deviation is minor and still readable.

    Tool Count5/5

    Five tools is well-scoped for a chess coaching server, and each tool covers a distinct part of the workflow: game discovery, analysis, mistake extraction, opening review, and engine diagnostics.

    Completeness4/5

    The surface covers the core coaching workflow from fetching games through analysis and opening review. Minor gaps exist, such as no player profile/rating lookup or explicit opening recommendation tool, but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables comprehensive chess analysis through Stockfish engine integration, positional evaluation, puzzle training, game review, and access to extensive chess databases. Provides visual board rendering, interactive game viewers, and tactical puzzle training with 3+ million problems from Lichess.
      34
      AGPL 3.0
    • A
      license
      B
      quality
      D
      maintenance
      Provides Chess.com player data integration, enabling AI assistants to fetch real-time chess player profiles and comprehensive statistics including ratings, game counts, and performance metrics from Chess.com's public API.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to explore player profiles, ratings, game archives, leaderboards, clubs, and puzzles via the Chess.com API.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      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.
      9 npm
      2
      MIT