Skip to main content
Glama
HexSet MCP Server

HexSet MCP Server

by 0xBrsm

HexSet

HexSet implements a hex-tile trading and building game based on the rules of Settlers of Catan: a NumPy rules engine, ONNX model inference, a browser interface, HTTP and MCP interfaces, Gymnasium and PettingZoo adapters, and batched environments for training and evaluation.

The engine covers resource production, construction, development cards, the robber, victory conditions and player trading. It owns the rules, information sets, encoding, game loops, seating and board pairing, records and replay, and trade evaluation. A training project supplies the model runtime and the learning algorithm through those interfaces; neural-network training and checkpoint export live in the sibling HexN project.

HexSet ships no playing bots. Its entrants are random (uniform over legal actions), retired (an empty seat), the network:, mcts: and rollout: checkpoint kinds (one forward per decision, PUCT search, paired rollouts), which need a model runtime, and catanatron, Catanatron's alpha-beta player seated at a HexSet table as an external reference (optional extra). The coalition: and handoff: wrappers seat any of them as a coalition member or hand a seat from one bot to another at a round. Every other bot is registered in process or joins over the API.

Documentation

Start with guide.md; the rest are listed by name.

Document

Contents

api.md

JSON routes, seat tokens, client identity and reclaim

evaluation.md

Designing a comparison, the intervals the runners report, experiment records

guide.md

Running games, trade rounds, implementing and registering a bot, records, bench commands, the public interface

hosted.md

A bot seat at a table hosted elsewhere: the observed game it plays forward

mcp.md

MCP tools and their semantics

native.md

Native game lanes: the optional C++ core, batched native requests, native playout copies

onnx.md

The ONNX model contract: record and decision graphs, metadata, committees, and checking a file against it

server.md

Running the server: configuration, Docker, saved games, the rankings

testing.md

Markers, optional extras, a complete check

trading.md

Trading's three parts: the table's rules, a gate's own TradeParams, the shared protocol; open offers and robber deals

training.md

Batched collection, the driver, model runtimes, search, decision observations, PettingZoo and Gymnasium adapters

worlds.md

Cached votes over sampled worlds

Related MCP server: rain-go

Your own bots

A bot is anything with choose(game) -> Action; trading is an optional gate (hexset.bots.Bot, TradeGate). It reaches a table in process or over the API.

In process. A module registers how to build it when imported:

from hexset.arena import Entrant, register_entrant_kind, register_preset

register_entrant_kind("mybot", lambda entrant, board, rng: MyBot(board, rng))
register_preset("mybot", Entrant("mybot", kind="mybot"))

Every command that names bots takes --runtime <module> (repeatable) and imports it first, in each worker process too:

python -m hexset.bench.duel mybot random --runtime mybots --games 400
python -m hexset.server.web --runtime mybots

HexSetEnv(opponents=("mybot",) * 3, runtime=("mybots",)) seats it in the Gymnasium wrapper. hexset.arena.load_runtime("mybots") is the same import in code; register_spec adds a parsed spelling (mybot:depth=3) beside a preset. A name means one bot: registering a different one under a taken name raises ValueError, HexSet's own names (random, retired, catanatron) and prefixes (network:, mcts:, rollout:, catanatron:, coalition:, handoff:) are refused, and unregister_* frees a name (docs/guide.md).

Over the API. A bot in any language joins a served table as a player (POST /api/join), reads /api/state and acts through /api/action, as a browser does (docs/api.md). python -m hexset.clients.botclient is an example of such a client. A Python bot that keeps an engine-side game in step with a table hosted elsewhere uses hexset.seat.Seat (docs/hosted.md).

Installation

Requires Python 3.11 or later. From the repository root:

pip install -e .

The base installation requires only NumPy. Installation also builds two optional C++17 extensions, a road-query core and the native game core (native.md); where no compiler is found it goes on without them and the Python engine plays every game. Install extras for the interfaces you use:

Extra

Provides

.[server]

ONNX Runtime for embedded model opponents

.[clients]

ONNX Runtime for standalone model clients

.[gym]

Gymnasium and PettingZoo environments

.[lanes]

greenlet, so hexset.lockstep runs its lanes as greenlets on one core instead of pinned threads

.[catanatron]

Catanatron integration, pinned to a specific Git commit

.[export]

ONNX and ONNX Runtime libraries; no training or export command is included

.[browser]

Playwright, for the browser tests; the browser itself is playwright install chromium

.[test]

pytest

Extras can be combined, for example pip install -e ".[server,gym,test]".

Play in a browser

python -m hexset.server.web

The server listens on http://127.0.0.1:8770 (--host, --port) and opens that URL in a browser unless --no-browser is given. Share a game's URL to invite other players. The New game button asks for the board (spiral, the default, or random) and whether to play the duel rules (15 points, discard above 9, a friendly robber and balanced dice, at two seats). A new game seats its creator and leaves the other seats open: all four without duel rules, and one with them, the other two closed for good. Fill open seats with people or bots, or close a seat with the picker's none option. Play starts once every seat is filled or closed. Until the first move a seat can be closed, reopened or given a bot, except at a duel table; after it the seats are fixed.

The opponent picker lists every preset a --runtime registered, catanatron when its extra is installed, and each *.onnx file in models/ (or $HEXSET_UI_MODELS_DIR) by the name its metadata declares, at the game types its modes declare (standard only when it declares none); the filename plays no part, its version is shown with it, and a file declaring no name is not listed. One name may be one file at some game types and another at the rest; two files offering one name at one game type are neither offered there. python -m hexset.clients.onnxmeta stamp names a file. The directory is rescanned on each listing, so a file dropped there appears without a restart; it must meet the ONNX model contract.

A bot or open seat's name opens the bot cards: one per bot the table's game type offers, with its version and the description its profile declares. Tapping a card seats that bot; before the first move the seat can be left open or closed instead.

The page plays other seats' actions back as they happen: captions at the foot of the board name each one, cards drawn as their glyphs, newest at the bottom; the dice roll, pieces drop in, the robber moves, and each seat's row shows the cards the action gained or lost it. Each action is held long enough to read, and a click on the board finishes the playback. A seat's own moves are drawn at once. A hex whose number comes up under the robber flashes red. A table's bots send each move as soon as they decide it. The speaker button in the board's top-left corner turns sound on for every seat's moves, off until a browser asks for it: recorded card, chip and dice clips and two end-of-game jingles, CC0, from Kenney's Casino Audio and Music Jingles.

The trade modal makes bank and port trades, offers to other players, and answers to their offers. A bot seat makes as many offers a turn as its own gate declares and waits for manual seats to answer. A manual seat has no card limit beyond its hand, and one holding no resource cards is passed on every offer.

GET /api/table/<code> needs no seat token and returns the whole game: every hand, development card and victory point. Anyone with the game URL can read it, players at that table included, so a served game does not keep hands secret between participants. Reads with a seat token filter hidden information.

A server started with --ranker also shows rankings at /rankings, and as a tab of the game page's menu. Only ranked games count: tables the server deals from a queue that API clients and models join, never the page. The server only shows them: the function --ranker names makes them from every ranked game (docs/server.md).

Configuration, Docker, journals and recovery are in docs/server.md.

Repository layout

Path

Contents

hexset/

Rules, board topology, state, ledger, encoding, records, search, and arena

hexset/bots/

The bot and trade-gate protocols, TradesBy, Coalition, the random policy, sampled worlds and search stances

hexset/bench/

Duels, baselines, trade censuses, throughput measurements and record generation

hexset/catanatron/

Seats a Catanatron Player as a bot at a HexSet table: board, state and action translation

hexset/server/

HTTP and MCP server, sessions, journals, and static browser UI

hexset/clients/

Runtime-independent policy, trade, and search interfaces; ONNX inference; bot clients

hexset/gym/

Lane, driver, PettingZoo, and Gymnasium environments

hexset/native/

The optional C++ game core and its Python bindings: native state, batched requests, playout copies

tests/

Engine and integration tests

models/

ONNX opponents the server's picker lists; empty as shipped

docs/

The documents indexed above

Tests

pip install -e ".[test,server,export,catanatron,gym,browser]"
playwright install chromium
pytest
pytest -m slow

The default run excludes tests marked slow; pytest -m "" runs every marker. Tests for an optional dependency skip themselves when it is absent, so the installed extras decide what a green run covered. docs/testing.md maps each extra to its tests, including the browser tests, which need a Chromium download beyond their extra.

License and attribution

HexSet is licensed under GPL-3.0-only. See LICENSE. Development history is in CHANGELOG.md; each release is also one commit here, whose message is that version's entry.

Dependencies are installed from PyPI or from git, never vendored into this repository, and each carries its own licence; the set and their extras are declared in pyproject.toml. Catanatron is GPL-3.0. The browser interface in hexset/server/static/index.html loads no third-party scripts, stylesheets or web fonts; its system font stack names fonts already on the user's device.

CATAN and SETTLERS OF CATAN are trademarks of Catan GmbH and Catan Studio. HexSet is not affiliated with, endorsed by, or sponsored by either company. The names identify the game whose rules this project implements.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables any local AI agent to play turn-based games over MCP by exposing reset, observe, and act verbs with structured observations and validated legal actions.
      6
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI and humans to play 10 board, card, and dice games together via MCP tools, with seat-based multiplayer and server-side hidden-hand isolation.
      21
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables MCP-compatible AI agents to play full Civilization VI games by reading game state and issuing rule-enforced actions such as moving units, managing cities, conducting diplomacy, and ending turns.
      76
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to connect to a running browser-based strategy game server and inspect state, issue validated moves and actions, manage cities, units, research, and production, chat, and receive turn/chat events without browser automation.
      AGPL 3.0