stockfish-lc0-mcp: Instructions file for Codex

AGENTS.md

stockfish-lc0-mcp AGENTS.md is an instructions file for Codex, OpenCode from alegerber/stockfish-lc0-mcp. It costs 3,296 tokens per session, scanned A, original, MIT.

Project instructions for an MCP server that lets programs communicate with Stockfish and Leela Chess Zero, two chess-analysis engines. It describes the server's TypeScript structure, tools, configuration, and engine behavior.

In plain words
What is it for?
Use it when working on the server's engine wrappers, chess utilities, input schemas, tool registration, Docker setup, or related TypeScript files.
Why use it?
It gives a coding agent the project context needed to change or maintain the chess-engine server consistently.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md.

This is alegerber/stockfish-lc0-mcp's own configuration. It tells Codex and OpenCode how to work on stockfish-lc0-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything stockfish-lc0-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to alegerber/stockfish-lc0-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/alegerber/stockfish-lc0-mcp/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/alegerber/stockfish-lc0-mcp

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for stockfish-lc0-mcp AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/alegerber/stockfish-lc0-mcp/agents-md/github.svg)](https://agentmods.dev/instructions/alegerber/stockfish-lc0-mcp/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/alegerber/stockfish-lc0-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/alegerber/stockfish-lc0-mcp/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for stockfish-lc0-mcp AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/alegerber/stockfish-lc0-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/alegerber/stockfish-lc0-mcp/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 3,296 This file is loaded in full into every session.
When invoked 3,296 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.03296 $0.03296
Opus 5 $0.01648 $0.01648
Sonnet 5 $0.00659 $0.00659
Haiku 4.5 $0.00330 $0.00330

Measured 9d ago against content hash a15006841027, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

stockfish-lc0-mcp AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 205 lines

How it starts

The opening of the file, as written. The whole thing — 205 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — Chess Engine MCP Server (Stockfish + Lc0)

Project Overview

MCP server wrapping UCI chess engines (Stockfish and Leela Chess Zero). Provides 8 tools for chess analysis over the Model Context Protocol stdio transport. Written in TypeScript (strict mode), runs on Node.js 22+ (CI-tested on LTS 22/24/26), deployed via Docker.

Both engines are enabled by default in Docker. Lc0 ships with the Maia-1900 neural network and uses the OpenBLAS CPU backend. Stockfish tools (sf_*) are always available. Lc0 tools (lc0_*) are conditionally registered when LC0_WEIGHTS_PATH is set (enabled by default in Docker).

Architecture

src/
├── index.ts              # Entry point: MCP server setup, tool registration, lifecycle
├── types.ts              # UciEngine interface, all TypeScript types, centipawns() helper
├── constants.ts          # Thresholds, defaults, starting FEN, Lc0 depth-to-nodes map
├── schemas/
│   └── index.ts          # Zod input schemas for all tools
├── services/
│   ├── engine.ts         # BaseUciEngine, StockfishEngine, Lc0Engine (spawn, send, parse)
│   ├── chess-utils.ts    # chess.js utilities: PGN parsing, FEN validation, opening book
│   └── formatting.ts     # Markdown formatting for analysis output
└── tools/
    ├── analyse-position.ts  # sf/lc0_analyse_position — single FEN analysis
    ├── analyse-game.ts      # sf/lc0_analyse_game — full PGN move-by-move analysis
    ├── openings.ts          # sf_lookup_opening, sf_identify_opening
    └── puzzle.ts            # sf/lc0_generate_puzzle — tactic puzzle generation
tests/
├── chess-utils.test.ts
├── formatting.test.ts
├── schemas.test.ts
├── constants.test.ts
├── types.test.ts
├── tools-openings.test.ts
├── tools-analyse-position.test.ts
├── tools-analyse-game.test.ts
└── tools-puzzle.test.ts

Key design decisions

  • UciEngine interface: All tools accept a UciEngine interface, not a concrete engine class. This allows Stockfish and Lc0 tools to share the same tool implementations.
  • BaseUciEngine abstract class: Shared UCI protocol logic (process spawn, sendAndWait, info line parsing) lives in BaseUciEngine. Subclasses (StockfishEngine, Lc0Engine) override configureOptions() and buildGoCommand().
  • Side-by-side tools: Stockfish (sf_*) and Lc0 (lc0_*) tools are registered in parallel. Opening tools (sf_lookup_opening, sf_identify_opening) are engine-agnostic and shared.
  • Lc0 depth-to-nodes mapping: Lc0 uses MCTS, where "depth" means something fundamentally different from alpha-beta depth. The depth parameter is mapped to node counts via LC0_DEPTH_TO_NODES in constants.ts for consistent UX.
  • WDL parsing: The UCI info line parser extracts Lc0's native wdl W D L data when present, stored in UciLine.wdl.
  • Engine as long-lived process: Each engine spawns one child process and reuses it across all tool calls. Commands are sent via UCI protocol over stdin/stdout.
  • Dual output: Every tool returns both content (Markdown text for display) and structuredContent (JSON for programmatic use).
  • Eval perspective: Both engines report scores from the side-to-move's perspective. Code that compares evals across moves must negate when the side-to-move changes. This is the most bug-prone area.
  • Win-probability accuracy model: Game analysis uses the Lichess win-probability formula (1 / (1 + exp(-0.00368208 * cp))) to compute per-move accuracy. Note: this was calibrated for Stockfish evals; Lc0 accuracy percentages may differ in calibration.
  • Terminal positions: Checkmate/stalemate/draw positions are detected before engine analysis to avoid garbage evals.

Read the full file on GitHub · 205 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 205 lines · 3,296 tokens per session scan A a15006841027

Subscribe to this mod's changes

stockfish-lc0-mcp AGENTS.md is an instructions file published in the GitHub repository alegerber/stockfish-lc0-mcp (2 stars, last pushed 14d ago), licensed MIT. It adds 3,296 tokens to every session, about $0.0165 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,153 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 3,735 tokens