Game Rooms
Multiplayer rooms for browser games: a signed-in host opens a room, friends join with a 5-character code and a nickname (no account), and everyone plays on one shared game state with fair server-side dealing, dice and secret moves. Games are defined once with define-game: rules_mode "config" lets the server enforce turns, who may change what and a state schema; "custom" leaves the rules to the game's own code. Pages use the game-rooms.js SDK; no keys in the page. Switch it on with configure {enabled: true}. Available on paid plans.
Endpoints (26)
Change the game room settings of this site. Only send what changes; reset lists settings to return to their default. enabled (default false) switches rooms on; false closes every open room at once. host_auth: who may open rooms, ["visitor","tenant"] (signed-in visitors via visitor auth, tenant members via tenant_auth). Limits: max_players, lobby_ttl_minutes, idle_ttl_minutes, hard_ttl_hours, max_state_kb, max_string_length, nickname_max, max_concurrent_rooms, max_rooms_per_host, join_rate_per_ip (per hour). allow_undefined_games lets hosts open rooms for games without a definition (custom mode). late_join is the default for letting players join after the start. Owner only.
| Field | Type | Required | Description |
|---|---|---|---|
enabled |
boolean | No | |
transport |
string | No | "poll" (default) or "push": every change reaches the players at once through the platform realtime service; the SDK falls back to polling when push is unavailable. Check push_available in get-config. |
host_auth |
array | No | Any of "visitor", "tenant". |
allow_undefined_games |
boolean | No | |
late_join |
boolean | No | |
max_players |
integer | No | Default 6. |
lobby_ttl_minutes |
integer | No | Default 30. |
idle_ttl_minutes |
integer | No | Default 120. |
hard_ttl_hours |
integer | No | Default 24. |
max_state_kb |
integer | No | Default 64. |
max_string_length |
integer | No | Longest text value in the state. Default 64, so the state cannot be used as a chat. |
nickname_max |
integer | No | Default 15. |
max_concurrent_rooms |
integer | No | Default 50. |
max_rooms_per_host |
integer | No | Default 3. |
join_rate_per_ip |
integer | No | Join attempts per network per hour. Default 120. |
reset |
array | No | Setting names to return to their default. |
Current settings, the stored overrides, the defaults and the platform ceilings.
No input parameters required.
Create or replace a game definition; every room of this game uses it. rules_mode "custom": the game's own code decides what is legal (the engine still keeps seats, privacy, versions, sizes, fair dealing and dice). rules_mode "config": rules = {turn_mode: free|round_robin|host|simultaneous, advance: explicit|after_update, turn_timeout_seconds (round_robin), writers: {state_key: any|turn|host|own_seat|none}, default_writer (default "none"), max_updates_per_turn (0 = no limit), state_schema (JSON Schema subset: type, properties, required, items, enum, minimum, maximum, minLength, maxLength, minItems, maxItems, additionalProperties)}. own_seat keys hold an object keyed by seat number; a seat may only change its own entry. decks = {"main": [card, ...]} (max 200 cards of 256 bytes); in config mode hosts can only deal these decks. The engine owns the state keys rolls, reveals, commit_status, deck_counts and hand_counts. Use initial_state_json / rules_json / decks_json (JSON strings) to keep empty objects {} and numeric keys exactly as written.
| Field | Type | Required | Description |
|---|---|---|---|
slug |
string | ✓ Yes | Lowercase id, e.g. "haaiehap". |
name |
string | No | |
rules_mode |
string | ✓ Yes | "config" or "custom". |
min_players |
integer | No | Default 2. |
max_players |
integer | No | Up to the site max_players. |
initial_state |
object | No | |
initial_state_json |
string | No | |
decks |
object | No | |
decks_json |
string | No | |
rules |
object | No | |
rules_json |
string | No |
One game definition with its version.
| Field | Type | Required | Description |
|---|---|---|---|
slug |
string | ✓ Yes |
All game definitions of this site (summary).
No input parameters required.
Delete a game definition. Open rooms keep running until they end or expire.
| Field | Type | Required | Description |
|---|---|---|---|
slug |
string | ✓ Yes |
Open rooms of this site with status and player counts. No game state and no nicknames.
| Field | Type | Required | Description |
|---|---|---|---|
status |
string | No | lobby, playing or finished. |
limit |
integer | No | Default 50, max 200. |
Close a room at once (its players see that the room ended).
| Field | Type | Required | Description |
|---|---|---|---|
room_id |
string | ✓ Yes |
Open rooms and players now, plus daily counters (rooms created, joins, failed joins, moves, version conflicts).
No input parameters required.
Open a room as host (seat 0). Needs a signed-in visitor or tenant session allowed by host_auth. Returns the seat token (keep it, it is the only key to this seat), the join code and the room. initial_state / initial_state_json only for custom games.
| Field | Type | Required | Description |
|---|---|---|---|
game |
string | ✓ Yes | |
max_players |
integer | No | |
nickname |
string | No | |
settings |
object | No | {late_join: bool} |
initial_state |
object | No | |
initial_state_json |
string | No |
Join a room with its code and a nickname (plain text, no links, e-mail addresses or phone numbers). Returns a seat token and the room.
| Field | Type | Required | Description |
|---|---|---|---|
join_code |
string | ✓ Yes | |
nickname |
string | ✓ Yes |
The room as this seat sees it; with since_version {changed:false} when nothing changed. Pages poll /game-rooms/poll instead (the SDK does).
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
since_version |
integer | No |
Change the shared state: state_json (whole new state) or patch_json (RFC 7396 merge patch), based on expected_version. 409 VERSION_CONFLICT when the room changed first: read again and redo. 422 when the move breaks the game rules.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
expected_version |
integer | ✓ Yes | |
state |
object | No | |
state_json |
string | No | |
patch |
object | No | |
patch_json |
string | No |
Replace this seat's private data (only this seat can read it), e.g. a secret code.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
data |
object | No | |
data_json |
string | No |
Pass the turn to the next player (round_robin games). The seat on turn or the host.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes |
Host: start the game. Closes the join code unless late_join is on.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes |
Host: remove a player from the room.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
seat |
integer | ✓ Yes |
Host: finish the game. The final state stays readable until the room expires.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes |
Host: close and delete the room now.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes |
Leave the room. A leaving host hands over to the next player; the last player leaving closes the room.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes |
Host: shuffle a deck on the server and deal per_seat cards to every player. deck = a deck name from the game definition; custom games may send their own list (deck / deck_json, name). Cards go to each player's private hand; the rest stays hidden on the server.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
deck |
string|array | No | Deck name, or (custom games) a list of cards. Or use deck_json. |
deck_json |
string | No | |
name |
string | No | |
per_seat |
integer | ✓ Yes | |
clear_hands |
boolean | No | Default true. |
shuffle |
boolean | No | Default true. |
Take n cards from a dealt deck into your hand.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
n |
integer | No | Default 1. |
deck |
string | No |
Play cards from your hand onto a list in the public state (target). Only cards that are in your hand. In config games the target must be a key listed in rules.writers; give it writer "none" so cards only get there by play.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
items |
array | No | |
items_json |
string | No | |
target |
string | ✓ Yes |
Hand in a secret move for a round. When every player has committed, all moves appear at once in state.reveals[round].
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
round |
string|integer | ✓ Yes | |
move |
string|array|number | No | |
move_json |
string | No |
Host: reveal a round now; players who did not commit get null.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
round |
string|integer | ✓ Yes |
Roll dice on the server (fair). The result is added to state.rolls for everyone to see.
| Field | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ Yes | |
sides |
integer | No | Default 6, max 1000. |
count |
integer | No | Default 1, max 20. |
MCP Tool Names
When using this integration through an AI assistant (Claude, ChatGPT, Cursor, etc.), the endpoints are available as MCP tools:
| Endpoint | MCP Tool Name |
|---|---|
| configure | game_rooms_configure |
| get-config | game_rooms_get_config |
| define-game | game_rooms_define_game |
| get-game | game_rooms_get_game |
| list-games | game_rooms_list_games |
| remove-game | game_rooms_remove_game |
| list-rooms | game_rooms_list_rooms |
| close-room | game_rooms_close_room |
| stats | game_rooms_stats |
| create-room | game_rooms_create_room |
| join-room | game_rooms_join_room |
| get-state | game_rooms_get_state |
| update-state | game_rooms_update_state |
| set-private | game_rooms_set_private |
| end-turn | game_rooms_end_turn |
| start | game_rooms_start |
| kick | game_rooms_kick |
| end | game_rooms_end |
| close | game_rooms_close |
| leave | game_rooms_leave |
| deal | game_rooms_deal |
| draw | game_rooms_draw |
| play | game_rooms_play |
| commit | game_rooms_commit |
| reveal | game_rooms_reveal |
| roll | game_rooms_roll |
Website