A FastAPI web app that runs Stockfish analysis on the server via MCP and generates the coaching report through the backend using a server-side OpenAI API key.
- The browser sends pasted PGNs to the FastAPI backend.
- The backend runs
mcp-stockfishand returns engine analysis JSON. - The browser sends that analysis plus the chosen side to the backend, which calls OpenAI and returns the coaching report.
- Replay is rendered in the browser with
chessboard-element.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000Open http://localhost:8000.
This repository includes render.yaml for a Docker-based Render deploy.
- Create a new Render Web Service from this repo.
- Render should detect the
Dockerfile. - Add these environment variables in Render:
OPENAI_API_KEY=<your key>
OPENAI_MODEL=gpt-4.1-mini
APP_LOG_LEVEL=INFO
MCP_ANALYSIS_MODE=movetime
MCP_ANALYSIS_MOVETIME_MS=300
MCP_ANALYSIS_DEPTH=12
MCP_ANALYSIS_MAX_PLIES=120
MCP_ANALYSIS_MAX_GAMES=5
OPENAI_API_KEY is now required on the backend.
This app is best deployed to Koyeb from the included Dockerfile because it needs:
- Python/FastAPI
- a Linux
stockfishbinary - a Linux-compatible
mcp-stockfishbinary
The Dockerfile handles all of that by:
- installing
stockfishwithapt - building
mcp-stockfish-persistentfor Linux fromsonirico/mcp-stockfish - starting
uvicornon Koyeb'sPORT
- Push this repository to GitHub.
- In Koyeb, create a new app from the GitHub repo.
- Choose Dockerfile deployment.
- Set the exposed HTTP port to
8000. - Set these environment variables if you want to tune analysis:
OPENAI_MODEL=gpt-4.1-mini
MCP_ANALYSIS_MODE=movetime
MCP_ANALYSIS_MOVETIME_MS=300
MCP_ANALYSIS_DEPTH=12
MCP_ANALYSIS_MAX_PLIES=120
MCP_ANALYSIS_MAX_GAMES=5
APP_LOG_LEVEL=INFO
Server-side OPENAI_API_KEY is required.
OPENAI_MODEL: model used server-side for report generation, defaultgpt-4.1-miniMCP_STOCKFISH_CMD: command used to start the MCP Stockfish processMCP_ANALYSIS_MODE:movetimeordepthMCP_ANALYSIS_MOVETIME_MS: default300inmovetimemodeMCP_ANALYSIS_DEPTH: default12indepthmodeMCP_ANALYSIS_MAX_PLIES: analyze at most N plies, default120MCP_ANALYSIS_MAX_GAMES: analyze at most N games from pasted input, default5APP_LOG_LEVEL:INFOorDEBUG
OPENAI_API_KEYmust be configured on the backend.- The user explicitly chooses whether they played as White or Black so the coaching is from the correct perspective.
- The engine mistakes table is based on Stockfish/MCP analysis from the backend.
- The interactive board uses CDN scripts (
chess.jsandchessboard-element).