ChessGraph-MCP
This read-only Neo4j MCP server lets an agent query a chess position graph for context, moves, transpositions, blunders, and endgame evidence.
Get a normalized position’s opening/endgame classifications plus stored eval, turn, piece count, visit count, material signature, last move, and best engine move.
List bounded played and theory moves from a position with target positions and move/game stats such as W/D/L, win rate, average CPL, clock, capture flag, and best move.
Find bounded transposition paths (up to
max_depth) through played/theory moves that converge on the same graph nodes.Retrieve recorded user blunders for a single game in ply order, including CPL, played/best moves, moved piece, clock, and game metadata.
Rank recurring blunder positions with occurrence/game counts, game IDs, and average/max CPL.
Fetch endgame patterns and bounded benchmark positions for a FEN, including endgame type, sample moves/FENs, Elo tier, and benchmark move.
Provides access to a positional graph knowledge base in Neo4j, with nodes for positions (FEN), edges for played moves ([:PLAYED]), and theory links ([:THEORY]), enabling GraphRAG-based chess analysis and semantic coaching.
Provides SQL access to chess game telemetry in PostgreSQL, including game type, ELO, results, ACPL, and blunder percentages, to support data-driven chess analysis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ChessGraph-MCP Evaluate 1.e4 e5 2.Nf3 and tell me if Nc6 is playable."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ChessGraph MCP
A local layer for personalized chess coaching
Connect an MCP-capable agent to personal game history, a positional knowledge graph, and reproducible Stockfish analysis—without giving the model unrestricted database access.
Deterministic analysis · Personal evidence · Typed MCP tools · Read-only by design
Why ChessGraph?
A chess engine can calculate excellent moves, but it does not know your history. A database can reveal recurring mistakes, but it cannot calculate the best move in a new position. A language model can explain ideas, but it should not invent the chess evidence behind them.
ChessGraph MCP separates those responsibilities:
Stockfish calculates candidate moves, evaluations, WDL, and principal variations.
PostgreSQL remembers games, move telemetry, openings, endgames, and historical engine evaluations.
Neo4j connects positions, your moves and your opponents' moves, theory moves, engine best moves, each game's path and milestones (where it left book, where it reached the endgame), mistakes, openings and endgame patterns.
The retrieval API serves those same reads to the interface, without asking the model to fetch the page.
Claude explains the combined evidence as a personalized lesson, through the
chessgraphClaude Code plugin.
The design principle is simple: the engine searches, deterministic code validates, the databases provide context, and the model explains only the evidence it receives.
Related MCP server: chess-coach-mcp
Architecture
flowchart LR
subgraph sources [Data sources]
pgn["Chess.com PGN archives"]
openings["Lichess opening theory"]
endgames["Endgame Atlas benchmarks"]
end
subgraph ingestion [Deterministic ingestion]
normalizer["ETL and FEN normalization"]
backfill["Historical Stockfish backfill"]
graphSync["PostgreSQL to Neo4j sync"]
end
subgraph knowledge [Local evidence stores]
postgres[("PostgreSQL: games and telemetry")]
neo4j[("Neo4j: position graph")]
end
subgraph runtime [Read paths]
api["FastAPI retrieval + in-app coach"]
pgMcp["PostgreSQL MCP: 9 tools"]
graphMcp["Neo4j MCP: 8 tools"]
sfMcp["Stockfish MCP: 3 tools"]
stockfish["Stockfish UCI"]
end
ui["React coach"]
host["Claude Code + chessgraph plugin"]
coach["Evidence-backed coaching response"]
pgn --> normalizer
openings --> normalizer
endgames --> normalizer
normalizer --> postgres
postgres -->|"unevaluated moves"| backfill
backfill -->|"scores and CPL"| postgres
postgres --> graphSync
graphSync --> neo4j
ui -->|"page facts"| api
ui -->|"questions (SSE)"| api
api -->|"tool loop"| claudeApi["Claude API"]
api -->|"repository reads"| postgres
api -->|"repository reads"| neo4j
api -->|"bounded search"| stockfish
host -->|"typed MCP calls"| pgMcp
host -->|"typed MCP calls"| graphMcp
host -->|"typed MCP calls"| sfMcp
pgMcp -->|"parameterized reads"| postgres
graphMcp -->|"bounded traversals"| neo4j
sfMcp -->|"serialized UCI"| stockfish
host --> coachThe ETL layer writes data. The MCP servers and the retrieval API only read.
They call the same repositories in chess_mcp/. MCP tools stay typed and
bounded for Claude. The API serves the facts the interface can draw before a
question is asked, such as the rating-band recap and the ranked training plan.
Claude explains; it does not assemble the page.
What the agent can ask
Evidence source | Best suited for | MCP capabilities |
PostgreSQL | Game selection, longitudinal statistics, move records, openings, endgames, ranked coaching briefs | 9 curated tools, paginated move retrieval, statement timeouts |
Neo4j | Theory versus personal choices, transpositions, recurring positions, graph context | 8 curated tools, anchored queries, maximum traversal depth |
Stockfish | Fresh position analysis, candidate comparison, WDL, legal variations | MultiPV, same-root move comparison, line validation |
Examples:
“Show my largest rapid-game mistakes and explain the top three.”
“Where did I leave opening theory, and what did I usually play instead?”
“Do different move orders in my games transpose into this position?”
“Compare my move with Stockfish's best move using the same search budget.”
“Which opening family scores worst for me, and what should I drill first?”
“Which positions keep tempting me into the same wrong move?”
“Which endgame patterns recur in my losses?”
Evidence flow for a coaching answer
sequenceDiagram
actor User
participant Coach as Claude (chess-coach)
participant PG as PostgreSQL MCP
participant Graph as Neo4j MCP
participant SF as Stockfish MCP
User->>Coach: Why was this move a mistake?
Coach->>PG: get_game_moves and get_blunders
PG-->>Coach: FEN, played move, CPL, clock, game context
Coach->>Graph: get_position_context and get_position_moves
Graph-->>Coach: Theory, personal choices, recurring patterns
Coach->>SF: compare_move from the same root
SF-->>Coach: Best line, played line, score, WDL, provenance
Coach->>SF: validate_line for any cited continuation
SF-->>Coach: Legal UCI, SAN, and resulting FENs
Coach-->>User: Verified explanation and actionable lessonPersonalized training
The training view is not a fixed lesson list. Both API endpoints behind it read the stored games and rank what to work on next.
GET /api/coach/brief returns the material a coach would open with:
the strongest opening families, by score in the stored games;
the target: the weakest opening family, with its wins, draws and losses;
calculation positions — repeated spots where the recorded move differs from
best_move_uci, ranked by frequency and average centipawn loss;the endgames field, which states plainly that endgame type is not stored on games rather than guessing one;
four tasks, each with a reason that quotes the stored record.
GET /api/coach/plan returns up to six ranked PlanItems. Each item carries a
kind (opening, defense, endgame or puzzle), the reason that justifies
it, a goal, a check_after_games review point, the line to drill, the player's
colour, and a ready flag.
A drill is only offered when it can actually be drilled: ready stays false
until the stored theory line for that family is at least MIN_DRILL_PLIES (6)
plies long, and the reason says how many plies it has. Drilled lines are capped
at TASK_PLIES (12). The interface shows the drill length next to the board, so
a short line is reported as short instead of silently passed off as a lesson.
Design guarantees
Read-only agent access
No arbitrary SQL or Cypher tools.
PostgreSQL uses parameterized statements, read-only transactions, local statement timeouts, and result caps.
Neo4j uses read transactions, parameterized values, indexed anchors, and a hard maximum path depth.
Database permissions remain the final security boundary; dedicated read-only accounts are recommended.
Reproducible engine evidence
Scores are normalized to the player at the root position.
Centipawn and mate scores remain distinct.
CPL is computed only when both comparable scores are centipawn scores.
compare_movesearches the best and played moves from the same root with the same requested budget.Principal variations are legally replayed in UCI and SAN.
Responses preserve engine identity, options, search limits, depth, nodes, and elapsed engine time when available.
Shared position identity
PostgreSQL and Neo4j use a four-field normalized FEN:
piece placement · side to move · castling rights · en-passant targetDropping move counters lets different move orders converge on the same position key. Stockfish receives a valid six-field FEN generated from that shared key.
Quick start
Prerequisites
Python 3.12+
Node.js 22+ and npm, for the React interface
PostgreSQL with the project schema and loaded data
Neo4j with the synchronized position graph
A local Stockfish binary
Claude Code for the coaching plugin
1. Install the project
uv syncThis installs three executable MCP servers:
.venv/bin/chessgraph-postgres-mcp
.venv/bin/chessgraph-neo4j-mcp
.venv/bin/chessgraph-stockfish-mcp2. Configure local services
cp .env.template .envSet the real values in .env:
POSTGRES_USER=chess_reader
POSTGRES_PASSWORD=change_me
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_DB=chess
CHESS_USERNAME=your_chess_username
NEO4J_URI=bolt://127.0.0.1:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=change_me
NEO4J_DATABASE=neo4j
STOCKFISH_PATH=/usr/games/stockfish
BACKEND_URL=http://127.0.0.1:8000CHESS_USERNAME is the Chess.com account stored in the games. Keep the real
value in .env. Do not copy it into CLAUDE.md, the plugin, or any tracked file. Search
budgets and the other limits are documented in
.env.template.
Both stores must be reachable before the interface or the coaches are useful:
PostgreSQL on 5432 and Neo4j on 7687. If Neo4j is down the coach says the
graph evidence is missing instead of guessing at it.
3. Load data if needed
If PostgreSQL and Neo4j are already populated, skip this step. Otherwise,
create the schemas from etl/sql_files/ and run:
uv run python etl/postgres_db/postgres_load.py
uv run python etl/postgres_db/load_stockfish_eval.py
uv run python etl/neo4j_db/neo4j_load.py --reset # deletes and reloads the chess labels onlyThe loaders mutate or rebuild data; the MCP servers never invoke them.
4. Install the Claude Code plugin
The coach, its skills, and the three MCP servers ship as the chessgraph
plugin. This repository is also its marketplace:
claude plugin marketplace add /path/to/ChessGraph-MCP
claude plugin install chessgraph@chessgraphOn first use, Claude Code asks for chessgraph_home, the absolute path of this
checkout. You can also set it with /plugin configure chessgraph@chessgraph.
The servers start with uv run --directory <chessgraph_home>, so they read this
repository's .env. No credential is stored in the plugin.
What you get:
Component | Use |
| Answers from the tools only, in positional terms |
| Evaluation, best move, why, and whether you reached it |
| Largest mistakes, same-root comparison, one lesson |
| Strengths, target family, four tasks |
| Your moves against theory, with scores |
| Are PostgreSQL, Neo4j and Stockfish up? |
Claude Code names the tools mcp__plugin_chessgraph_<server>__<tool>. For
example:
mcp__plugin_chessgraph_postgres__get_blunders
mcp__plugin_chessgraph_neo4j__get_position_moves
mcp__plugin_chessgraph_stockfish__compare_movePostgreSQL and Neo4j may serve parallel reads. Stockfish calls stay serialized,
because one persistent UCI process serves that server. See
docs/plugin.md.
5. Verify
uv run pytestOptional live-service tests:
CHESSGRAPH_RUN_INTEGRATION=1 uv run pytest tests/test_integration.pyInspect a server with the official MCP development tooling:
uv run mcp dev chess_mcp/stockfish/server.py6. Run the retrieval API
uv run uvicorn backend.main:app --host 127.0.0.1 --port 8000Nineteen routes serve the interface, the coaching reads, and the coach:
Route | Purpose |
| Liveness check |
| Player summary: games, results, average ratings, date range |
| Rating-band recap: win rate, lines, clocks, results |
| Filter games by player, type, outcome, ECO, and date |
| One game's metadata and movetext |
| Paged moves and stored evaluations |
| Opening lessons for a colour |
| Endgame lessons for the player's rating tier |
| Strengths, weakest target, calculation, four tasks |
| The ranked training plan |
| Opening theory for an exact normalized position |
| Neo4j position context and outgoing moves |
| Book, your and your opponents' moves from a position, and your games through it |
| Bounded MultiPV analysis |
| One played move against the best move, same root |
| Replay a UCI line into legal SAN and FENs |
| One opponent move at a chosen strength ( |
| The in-app coach, streamed as server-sent events |
| Whether the coach runs on Claude or offline |
The UI proxies /api to BACKEND_URL. See backend/README.md.
The Stockfish routes start their own engine on first use. /api/engine/play
uses a second process, so a weakened opponent never weakens analysis. The
Stockfish MCP server keeps a separate engine of its own.
7. Run the UI
cd ui
npm install
npm run devOpen http://127.0.0.1:5173. Every board view puts the board first, sized to the window, with one tabbed panel beside it (below it on a phone). The app has three modes:
Home — the default view. A rating-band recap counted from PostgreSQL through
GET /api/recap. Pick a band and the charts recompute; each card opens into the chart and table behind it. The favourite line in a band is the stored opening name with the most games, so a line that was played can still rank behind a larger one.Play & train — play Stockfish at a chosen strength (matched to your average rating until you pick one) with a real clock, takeback, resign and PGN copy, or drill the ranked plan from
GET /api/coach/plan. Tabs: Play (new game and lessons), Moves, Coach, Explorer.My games — stored games grouped by time control. A game opens at its recorded key moment; the move table marks
?!,?and??from stored centipawn loss. Tabs: Games, Moves, Coach, Explorer.
The Explorer tab reads graph v2 through GET /api/explorer: book moves, your
moves and your opponents' moves from the position on the board, with games and
scores, and your recent games through it. ← → step through moves, Home/End jump,
F flips the board.
Every panel is a live read: the recap, games, lessons, coaching brief, plan, and position analysis all come from the retrieval API. There is no sample data in the interface.
The in-app coach
The coach panel posts to POST /api/coach/chat, and the API streams the answer
back as server-sent events. The UI lights each evidence chip (Games, Graph,
Stockfish) as the matching tool runs.
The coach has two modes:
Claude. Used when
ANTHROPIC_API_KEYis set in.env.The API runs a tool loop on the Messages API (
CLAUDE_MODEL, defaultclaude-opus-5-5, with effortCLAUDE_EFFORT, defaultlow).It uses fourteen read-only tools that mirror the MCP contracts.
Usernames are replaced by "you" and "opponent" before any tool result leaves the machine.
CLAUDE_REFUSAL_FALLBACK=defaultlets the API retry a refused turn on a fallback model.
Offline evidence. Used when there is no key, or when
COACH_MODE=offlineis set.The same tools run in a fixed plan: a position question gets Stockfish plus the graph, a training question gets the coaching brief, and a game question gets the largest mistakes plus a same-root comparison.
The results are printed without a model and labelled as offline.
The key stays in the API process. See backend/README.md.
Other UI commands:
cd ui
npm test # clock rules, statistics, plan ranking, and coach transport
npm run lint # oxlint
npm run build # type-check and production bundle
npm run preview # serve the production bundleSee ui/README.md for the interface structure and libraries.
MCP surface
Tool | Purpose |
| Filter games by player, type, outcome, ECO, and date |
| Retrieve one game's metadata and PGN movetext |
| Page through ordered moves, FENs, clocks, and evaluations |
| Aggregate results and ratings |
| Find the data owner's or a named player's evaluated mistakes |
| Rank opening families by result and surface repeated mistakes |
| Find games containing an exact normalized FEN |
| Retrieve opening theory for a position |
| Retrieve filtered endgame benchmarks |
Resource: chessgraph://postgres/schema
Tool | Purpose |
| A position with phase, stored eval, openings, endgame type and engine best move |
| Theory moves and played moves, split into yours and your opponents' |
| Find bounded paths to positions several move orders reach |
| Your mistakes in one game, filtered by severity |
| Positions where you went wrong in several games |
| Endgame patterns and benchmark positions |
| Your games that reached a position, and your score from it |
| Where your games leave opening theory |
Resource: chessgraph-neo4j://schema
Tool | Purpose |
| Run bounded depth, node, or time-based MultiPV analysis |
| Compare a legal played move with the best move from one root |
| Replay UCI moves and return legal SAN/FEN evidence |
Resource: chessgraph-stockfish://capabilities
See docs/mcp.md and the package-specific READMEs under
chess_mcp/ for contracts, semantics, and extension guidance.
Project structure
ChessGraph-MCP/
├── chess_mcp/ modular MCP package
│ ├── postgres/ relational repositories, recap, training plan, server
│ ├── neo4j/ graph repositories, models, server
│ └── stockfish/ UCI lifecycle, scoring, models, server
├── etl/
│ ├── postgres_db/ game, theory, and engine-evaluation loaders
│ ├── neo4j_db/ graph synchronization
│ └── sql_files/ PostgreSQL schema
├── backend/ FastAPI reads for the UI
├── ui/ React coach, all panels reading the API
│ └── src/
│ ├── views/ Home, Play & train, and My games
│ ├── data/ API-backed reads plus name and type helpers
│ ├── lib/ chess rules, clocks, evaluations, graph, stats
│ ├── components/ board, coach panel, eval bar, cards
│ └── services/ coach transport and engine calls
├── plugins/chessgraph/ Claude Code plugin: MCP servers, coach agent, skills
├── .claude-plugin/ local marketplace manifest
├── docs/ operations and MCP reference
├── tests/ unit and opt-in integration tests
├── CHESS.md chess-domain reference
└── STOCKFISH.md engine and NNUE referenceData sources
Personal PGN archives exported from Chess.com
Dataset licenses and terms remain those of their respective publishers. Personal game records may contain usernames and should be treated as private data.
Current scope
ChessGraph MCP is a local evidence layer, not a complete coaching application. It currently provides:
local stdio MCP servers, packaged as a Claude Code plugin;
a FastAPI retrieval process for the interface, using the same repositories;
read-only runtime tools, with no arbitrary query surface;
existing-data analysis over the loaded games;
ranked coaching briefs and a training plan derived from those games;
deterministic validation and typed evidence;
a local React interface for Home, Play & train, and game review, reading the API rather than carrying sample data.
The coach persona and skills live in plugins/chessgraph/.
Project instructions for Claude Code live in CLAUDE.md.
Not yet built: persisting lessons or drilling history back into the stores, running the retrieval API as a remote HTTP or OAuth service, and automatically verifying every natural-language strategic claim the model produces. The training plan ranks what to work on next; it does not yet record whether a drill was completed.
Documentation
License
Released under the MIT License.
Available Tools
6 toolsfind_transpositionsCRead-onlyIdempotent
Find bounded move paths from a position to convergent graph nodes.
Inputs: fen (required), limit, max_depth. Returns: paths, fen_norm, max_depth
get_endgame_contextCRead-onlyIdempotent
Get endgame classifications and bounded benchmark positions for a FEN.
Inputs: fen (required), limit. Returns: patterns, position, benchmarks
get_game_blundersBRead-onlyIdempotent
List recorded user blunders for one game in ply order.
Inputs: game_id (required), limit. Returns: game_id, blunders
get_position_contextBRead-onlyIdempotent
Get a normalized position with its opening and endgame classifications.
Inputs: fen (required). Returns: openings, position, endgame_patterns
get_position_movesCRead-onlyIdempotent
List bounded played and theory moves leaving a normalized position.
Inputs: fen (required), limit. Returns: moves, fen_norm
get_recurring_blunder_positionsCRead-onlyIdempotent
Rank positions linked to blunders in multiple recorded events.
Inputs: limit, min_occurrences. Returns: positions, min_occurrences
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools have clearly distinct purposes: position context, moves, transpositions, per-game blunders, recurring blunder positions, and endgame context. There is some overlap between get_position_context and get_endgame_context because both involve endgame classifications, and get_position_moves vs find_transpositions both concern moves from a position, but the distinctions are manageable.
All tool names use snake_case with a clear verb_noun pattern, mostly get_ and one find_. The naming is predictable and readable throughout.
Six tools is well-scoped for a focused chess graph analysis server. Each tool covers a distinct analytical operation without obvious redundancy.
The surface covers core read-only analytics: position context, moves, transpositions, blunders, recurring blunders, and endgame context. Minor gaps may exist around discovering game IDs or broader search/listing operations, but core workflows appear covered.
Maintenance
Related MCP Connectors
Free chess tools for AI agents: Stockfish best move, evaluation, openings and game analysis.
Pedagogical chess intelligence for AI agents: explain positions and games for a target Elo.
Stockfish 17.1 chess engine for AI assistants: best moves, FEN checks, legal moves, move lists.
Stockfish chess eval: best move, score, principal variation, multipv. $0.005/call via x402.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables 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.35AGPL 3.0
- AlicenseAqualityDmaintenanceA hybrid AI chess coach MCP server that uses Stockfish for grounded evaluation and LLM for natural-language coaching, enabling game analysis, weakness diagnosis, and personalized drills from your own games.65MIT
- AlicenseAqualityBmaintenanceMCP chess runtime that lets LLMs play, analyze, and adapt strength by exposing Stockfish, human move likelihood (Maia3), and Lichess statistics, with the LLM handling strategy and the server handling computation.13AGPL 3.0
- FlicenseNot gradedqualityDmaintenanceEnables local Stockfish-powered chess game analysis, mistake classification, puzzle finding and generation, and study-resource recommendations through MCP tools.-