bb-gnubg-mcp
Provides tools for analyzing backgammon positions, evaluating moves, and running rollouts using the GNU Backgammon neural network engine.
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., "@bb-gnubg-mcp Analyze this backgammon position: 4HPwATDgc/ABMA"
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.
bb-gnubg-mcp
MCP server wrapping the GNU Backgammon neural network evaluation engine. Exposes 18 tools for position analysis, move evaluation, rollouts, and board conversion via the Model Context Protocol.
Requirements
Python 3.13+
Related MCP server: Leela MCP Server
Installation
git clone <repo-url>
cd bb-gnubg-mcp
uv syncRunning Locally (stdio)
The default transport is stdio, suitable for use with Claude Code and other MCP clients:
uv run python -m bb_gnubg_mcpOr via the installed script:
uv run bb-gnubg-mcpClaude Code Configuration
Add to your Claude Code MCP settings:
{
"mcpServers": {
"bb-gnubg-mcp": {
"command": "uv",
"args": ["run", "--directory", "/path/to/bb-gnubg-mcp", "python", "-m", "bb_gnubg_mcp"]
}
}
}Running Locally (HTTP)
For HTTP transport with API key authentication:
export MCP_TRANSPORT=http
export API_KEY=your-secret-key
export PORT=8000 # optional, defaults to 8000
uv run python -m bb_gnubg_mcpThe server starts on http://0.0.0.0:8000 with:
Streamable HTTP MCP transport
Bearer token auth on all tool calls (pass
Authorization: Bearer <API_KEY>)Health check at
GET /health
Docker
Build
docker build -t bb-gnubg-mcp .Run
docker run -p 10000:10000 \
-e API_KEY=your-secret-key \
bb-gnubg-mcpThe Dockerfile uses a multi-stage build with uv. The image defaults to HTTP transport on port 10000.
Override settings
docker run -p 8080:8080 \
-e API_KEY=your-secret-key \
-e PORT=8080 \
-e MAX_ROLLOUT_GAMES=5000 \
bb-gnubg-mcpDeploy to Render
Push this repo to GitHub.
In the Render dashboard, click New > Blueprint and connect your GitHub repo.
Render detects
render.yamland creates the service automatically.Set the
API_KEYenvironment variable in the Render dashboard (it's markedsync: falsein the Blueprint so it won't be committed to source).Deploy. The health check at
/healthconfirms the service is running.
Alternatively, create the service manually:
New > Web Service in Render.
Connect your GitHub repo.
Set Environment to Docker.
Add environment variables:
MCP_TRANSPORT=httpPORT=10000API_KEY= your secret key
Set Health Check Path to
/health.Deploy.
Auto-deploy is enabled — pushing to the connected branch triggers a new deployment.
Tools
Board Conversion
Tool | Description |
| Position ID string to 2x25 board |
| Position key string to 2x25 board |
| Board (any format) to Position ID |
| Board (any format) to position key |
Position Analysis
Tool | Description |
| Classify position type (contact, race, bearoff, etc.) |
| Win/gammon/backgammon probabilities via neural net |
| Fast heuristic evaluation score |
Move Evaluation
Tool | Description |
| Best move with alternatives, probabilities, and equity |
| Best move via fast public evaluation |
| All legal moves for a position and dice roll |
Simulation
Tool | Description |
| Cubeless Monte Carlo rollout |
| Cubeful Monte Carlo rollout |
Bearoff
Tool | Description |
| Bearoff ID to 6-point position |
| Probability distribution for bearing off in N moves |
| Win probability for single-checker bearoff |
Utility
Tool | Description |
| Roll two dice |
| Match equity table lookup |
| List all GNUBG constant names and values |
Board Input Formats
All tools that accept a board position support three formats:
JSON boardState (matching the bb-plays-mcp convention):
{
"board": {
"x": {"24": 2, "13": 5, "8": 3, "6": 5},
"o": {"24": 2, "13": 5, "8": 3, "6": 5}
},
"player": "x"
}Position ID (14-character GNUBG string):
"4HPwATDgc/ABMA"Raw 2x25 array (as returned by gnubg):
[[0,0,0,0,0,5,0,3,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,2,0],
[0,0,0,0,0,5,0,3,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,2,0]]Environment Variables
Variable | Default | Description |
|
| Transport mode: |
| — | Required for HTTP mode. Bearer token for auth. |
|
| HTTP listen port |
|
| Maximum games per rollout call |
Tests
uv run pytest # all tests (rollouts are slow)
uv run pytest -m "not slow" # skip rollout testsAvailable Tools
18 toolsbearoff_id_2_posC
Convert a bearoff ID to a 6-point position tuple.
Args: bearoff_id: Either an integer bearoff ID or a 6-element list.
Returns: Dict with the 6-point position (checkers on points 1-6).
Inputs: bearoff_id (required). Returns: object
bearoff_probabilitiesC
Get the probability distribution of bearing off in N moves.
Args: bearoff_id: Either an integer bearoff ID or a 6-element list.
Returns: Dict with probability distribution of bearing off in 1, 2, ..., N moves.
Inputs: bearoff_id (required). Returns: object
best_moveA
Find the best move for a position and dice roll using neural network evaluation.
Args: board_input: Board in any supported format. dice: Dice roll as [die1, die2], each 1-6. player: Who is on roll ("x" or "o"). Default "x". ply: Evaluation depth (0, 1, or 2). Higher is stronger but slower. score: Match score as [x_away, o_away]. Omit for money game. cube: Cube state as {"owner": "C"/"X"/"O", "value": 1, "centered": true}. seed: RNG seed for reproducibility.
Returns: Dict with best_move notation, alternatives with probabilities, and board after move.
Inputs: dice (required), board_input (required), ply, cube, +3 more. Returns: object
board_from_position_idA
Convert a 14-character GNUBG Position ID to a board representation.
Args: position_id: A 14-character GNUBG Position ID string (e.g. "4HPwATDgc/ABMA").
Returns: Dict with the 2x25 board array and the position ID.
Inputs: position_id (required). Returns: object
board_from_position_keyA
Convert a GNUBG position key string to a board representation.
Args: position_key: A GNUBG position key string.
Returns: Dict with the 2x25 board array, position ID, and key.
Inputs: position_key (required). Returns: object
classifyA
Classify a board position into one of GNUBG's position types.
Args: board_input: Board in any supported format. player: Who is on roll ("x" or "o"). Required if board_input is a boardState dict.
Returns: Dict with classification name and numeric code. Classifications: "over", "bearoff", "race", "crashed", "contact".
Inputs: board_input (required), player. Returns: object
cubeful_rolloutA
Perform a cubeful rollout with doubling cube handling.
Args: board_input: Board in any supported format. player: Who is on roll ("x" or "o"). Default "x". ngames: Number of games to simulate (default 576, max configurable). ply: Evaluation depth (0, 1, or 2). score: Match score as [x_away, o_away]. Omit for money game. cube: Cube state dict. seed: RNG seed for reproducibility.
Returns: Dict with detailed rollout statistics including cubeful equity.
Inputs: board_input (required), ply, cube, seed, +3 more. Returns: object
equities_valueA
Look up match equity for a given match score.
Args: x_away: Points player X needs to win the match (0-25). o_away: Points player O needs to win the match (0-25).
Returns: Dict with match winning chance (MWC) for player X.
Inputs: o_away (required), x_away (required). Returns: object
get_constantsA
Get all GNUBG constant values used by other tools.
Returns: Dict with position_classes, evaluation_modes, and rollout_types. Use these string names as parameter values in other tools.
Inputs: no named parameters. Returns: object
key_of_boardA
Convert a board to its GNUBG position key string.
Args: board_input: Board in any supported format. player: Who is on roll ("x" or "o"). Required if board_input is a boardState dict.
Returns: Dict with the position key string.
Inputs: board_input (required), player. Returns: object
movesA
Generate all legal moves for a board and dice roll.
Args: board_input: Board in any supported format. dice: Dice roll as [die1, die2], each 1-6. player: Who is on roll ("x" or "o"). Default "x".
Returns: Dict with list of legal moves, each with notation, steps, and position key.
Inputs: dice (required), board_input (required), player. Returns: object
one_checker_raceA
Estimate win probability for a one-checker bearoff race.
Args: pips: Number of pips remaining to bear off a single checker.
Returns: Dict with equity and standard deviation, or null if unsupported.
Inputs: pips (required). Returns: object
position_idA
Convert a board to its 14-character GNUBG Position ID.
Args: board_input: Board in any supported format (boardState dict, Position ID string, or 2x25 list). player: Who is on roll ("x" or "o"). Required if board_input is a boardState dict.
Returns: Dict with the position ID string.
Inputs: board_input (required), player. Returns: object
probabilitiesB
Calculate win/gammon/backgammon probabilities for a position.
Args: board_input: Board in any supported format. evaluation_mode: Evaluation strategy. One of: "prune", "race", "osr", "bearoff", "0plus1", "1sbear", "1srace". player: Who is on roll ("x" or "o"). Required if board_input is a boardState dict. nr: Number of rollouts for OSR mode (default 1296). score: Match score as [x_away, o_away]. Omit for money game. cube: Cube state as {"owner": "C"/"X"/"O", "value": 1, "centered": true}. seed: RNG seed for reproducibility.
Returns: Dict with win, win_gammon, win_backgammon, lose_gammon, lose_backgammon probabilities.
Inputs: board_input (required), nr, cube, seed, +3 more. Returns: object
pub_best_moveA
Find the best move using GNUBG's public (non-neural, fast) evaluation.
Args: board_input: Board in any supported format. dice: Dice roll as [die1, die2], each 1-6. player: Who is on roll ("x" or "o"). Default "x".
Returns: Dict with move as from/to pairs and notation.
Inputs: dice (required), board_input (required), player. Returns: object
pub_eval_scoreA
Compute a fast heuristic evaluation score using GNUBG's public (non-neural) model.
Args: board_input: Board in any supported format. player: Who is on roll ("x" or "o"). Required if board_input is a boardState dict.
Returns: Dict with the evaluation score. Positive favors the mover, negative favors opponent.
Inputs: board_input (required), player. Returns: object
rollA
Simulate a roll of two six-sided dice.
Returns: Dict with die1 and die2 values (1-6 each).
Inputs: no named parameters. Returns: object
rolloutA
Perform a cubeless Monte Carlo rollout of a position.
Args: board_input: Board in any supported format. player: Who is on roll ("x" or "o"). Default "x". ngames: Number of games to simulate (default 1296, max configurable). ply: Evaluation depth per move (0, 1, or 2). rollout_type: Rollout mode: "auto", "race", "bearoff", "over". score: Match score as [x_away, o_away]. Omit for money game. cube: Cube state dict. seed: RNG seed for reproducibility.
Returns: Dict with win probabilities and standard deviations.
Inputs: board_input (required), ply, cube, seed, +4 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
The four board/position conversion tools (board_from_position_id, position_id, key_of_board, board_from_position_key) are clearly paired but could be misselected due to similar naming. Other tools like best_move vs pub_best_move and rollout vs cubeful_rollout are distinct but share comparable names, though descriptions help.
Tool names use a mix of conventions: verb_noun (get_constants), noun phrases (best_move, probabilities), and abbreviations (bearoff_id_2_pos, pub_eval_score). No consistent verb pattern is present, but names are descriptive and readable.
With 18 tools, the server is on the heavy side, exceeding the typical 3-15 well-scoped range. However, each tool serves a distinct backgammon analysis function, so the count is justified by the broad domain.
The tool set covers position representation, evaluation, move generation, rollouts, bearoff, and match equity—a complete lifecycle for backgammon analysis. There are no obvious dead ends or missing critical operations.
Maintenance
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
Remote MCP server for D&D: read and update your CharGen campaigns, generate NPCs and art.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Remote MCP server for deterministic educational practice-assessment score conversions.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA powerful chess engine and game server built with the Model Context Protocol (MCP). Play chess against AI, analyze positions, and integrate chess functionality into your AI applications.48 npm1ISC
- AlicenseNot gradedqualityDmaintenanceAn MCP server that exposes the Leela Chess Zero neural-network chess engine to MCP clients, enabling position analysis, best move calculation, and board manipulation.MIT
- FlicenseAqualityDmaintenanceEnables chess analysis and move generation using the Stockfish engine via MCP tools, allowing clients to evaluate positions, get best moves, apply moves, and visualize boards.7-
- 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.1331 npmAGPL 3.0