The UCI Protocol

UCI (Universal Chess Interface) is the text protocol that chess interfaces use to talk to engines like Stockfish. If you've ever wondered how analysis works under the hood, this is it.

How a session works

The GUI sends commands on standard input; the engine replies on standard output. A minimal exchange looks like this:

uci
isready
position startpos moves e2e4 e7e5
go depth 15
bestmove g1f3

Key commands

uci handshakes and lists options; isready waits for the engine; position sets the board (from startpos or a fen) plus a list of moves; go starts searching; stop halts it.

UCI move format

Engines speak long algebraic: the from-square and to-square, e.g. e2e4, with a promotion piece appended like e7e8q. This differs from SAN (e4, e8=Q) used in PGN.

Reading the output

While thinking, the engine streams info lines with depth, score cp (centipawns) and the principal variation pv. It finishes with bestmove. ChessBhumi's analysis uses exactly this when a UCI engine is configured.