Skip to main content
Glama

Game2AgentProtocol (GAP)

A minimal protocol that lets any local AI agent play any turn-based game, served over MCP so it works out of the box with Claude Code, Claude Desktop, Cursor, OpenAI Agents SDK, LangChain — anything that speaks MCP. Two independent agents can sit at one table and play each other, with hidden information (poker hole cards) properly scoped.

Docs: RESEARCH.md (landscape research + why this design) · MEMORY.md (state + next steps) · AGENTS.md / CLAUDE.md (instructions for AI coding agents).

The protocol (GAP v0.2)

A game is agent-playable when it implements three verbs (gap.py):

Verb

Meaning

Returns

reset()

start a fresh game

Observation

observe(seat=None)

current state, from one seat's viewpoint

Observation

act(action)

apply one action (a string)

Observation

Every Observation carries: state_text (LLM-readable board), legal_actions (the only strings act accepts), turn, seat, done, result, and structured (machine extras like FEN). Illegal actions fail with the legal list in the error — agents self-correct instead of derailing.

Adapters (adapters.py): chess (python-chess), tic-tac-toe (stdlib), and poker (No-limit Texas Hold'em via PokerKit — hidden information: each seat only ever sees its own hole cards).

Related MCP server: sts1

MCP tools

list_games · reset(game, table) · join(table, seat) → secret seat_token · observe(table, seat_token) · act(table, action, seat_token) · wait_turn(table, seat_token, timeout_s) (blocks until it's your turn — the turn-arbitration primitive).

Quickstart — solo agent (stdio)

uv sync && uv run python test_gap.py     # self-check
claude mcp add gap -- uv run --directory /path/to/Game2AgentProtocol game2agent
claude "play a game of chess against yourself using the gap tools"

(Claude Desktop: same command under mcpServers in its config.)

Two agents, one table (shared HTTP server)

game2agent serve          # one shared server at http://127.0.0.1:8423/mcp

In each agent's session:

claude mcp add --transport http gap http://127.0.0.1:8423/mcp

Each agent runs the same loop: join(table, seat) once, then wait_turn → pick from legal_actions → act, until done. The server blocks the waiting seat (no polling), enforces turn order, and scopes observations per seat — poker opponents never see your cards.

Design decisions

  • MCP, not a new wire protocol. Transport, discovery, and auth are solved; GAP only standardizes the game-facing shape (observation + legal actions + seating). Full rationale in RESEARCH.md.

  • Turn-based blocking. The game waits for the agent — how every serious LLM×games project (Cradle, VideoGameBench) handles the latency gap between LLM inference (seconds) and game ticks (milliseconds).

  • Seat tokens, not player ids. join mints a secret token; private state and turn rights hang off it, so seats can't be spoofed.

  • Server-side validation. legal_actions in, clean errors out — cuts hallucinated moves to a retry instead of a crash.

Roadmap

  • Publish: PyPI (uvx game2agent) + official MCP Registry listing.

  • Multi-hand poker (button rotation, configurable stakes/seats).

  • OpenSpiel or TextArena bridge adapter — ~70 games in one stroke.

  • Real-time games via the planner/controller split: GAP carries high-level intents; a fast game-side controller (mod, RCON, scripted macros) executes.

Available Tools

6 tools
actA

Play one action (must be in your legal_actions). Returns your new observation.

On a table with claimed seats you must pass your seat_token, and it must be
your turn.

Inputs: table (required), action (required), seat_token.

joinA

Claim a seat at a table (a specific one, or the next open one).

Returns your secret seat_token — pass it to wait_turn/observe/act. Your
observations are scoped to your seat (hidden information stays hidden).

Inputs: table (required), seat.

list_gamesA

List available games (with action grammar), active tables, and their open seats.

Inputs: no named parameters.

observeB

Current observation for a table — seat-scoped if you pass your seat_token.

Inputs: table (required), seat_token.

resetA

Start a fresh game on a table and return the initial observation.

table names the session so several games can run concurrently (defaults to
the game name). Solo play: just call act() next. Multi-agent play: each
agent calls join() to claim a seat, then loops wait_turn() -> act().

Inputs: game (required), table.

wait_turnA

Block until it is your seat's turn (or the game ends, or timeout).

On timeout the observation comes back with your_turn=false — just call
wait_turn again. Keep timeout_s below your client's tool timeout.

Inputs: table (required), seat_token (required), timeout_s.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct operation: reset starts a game, join claims a seat, observe reads state, act changes state, wait_turn blocks for turn changes, and list_games enumerates available games and tables. There is no meaningful overlap or ambiguity between their purposes.

    Naming Consistency4/5

    Tool names are all lowercase imperative verbs, with compound names using snake_case (wait_turn, list_games). The style is consistent and readable, though bare verbs like act and observe are less descriptive than verb_noun patterns.

    Tool Count5/5

    Six tools form a well-scoped set for a game-session server: setup, joining, turn handling, acting, observing, and discovery. Nothing feels redundant or missing at the count level.

    Completeness4/5

    The core game lifecycle is covered: create/start, join, observe, act, wait, and list. Minor gaps exist such as no explicit leave/seat-release or table-close operation, but agents can work around them using the available surface.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP agents to play chess locally, supporting join, state, legal moves, and move execution with per-session color ownership.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      This MCP server lets AI clients retrieve Slay the Spire game state and decision packs, and perform in-game actions such as playing cards, ending turns, running turns, and flushing observations.
      12
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables turn-based board games to be served through MCP by tracking sessions, seats, and moves, running AI turns, supporting second-player joins from another device, saving sessions, and offering move menus, rules teaching, and a web debug page. It includes no game rules; users register their own games, which supply all rules.
      Apache 2.0
    • 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