Custom games API
JParty lets you store your own Jeopardy games as JSON files on the server and load them from the host page by ID. Two parallel surfaces manage that store:
- REST — unauthenticated, meant for the in-browser
editor at
/editor. Available on the local network without a token. - MCP — for AI agents. Mounted at
/mcpusing the Model Context Protocol Streamable HTTP transport. Gated by a bearer API key generated and persisted in the server's data directory.
Both surfaces back onto the same on-disk store
($JPARTY_DATA_DIR/games/<id>.json). Every write goes
through the same validator, so a game created by an agent is
indistinguishable from one created in the editor.
Game ID rules
- Allowed characters:
A-Z,a-z,0-9,-,_. - Length: 1–32 characters.
- MUST NOT be a pure 1–6 digit number — that pattern is reserved for J-Archive routing on the host page's Load box.
REST endpoints
All responses are JSON. Errors come back with the FastAPI shape
{"detail": "<message>"} and a 4xx status.
| Method | Path | Description |
|---|---|---|
| GET | /api/games |
List all games as summaries (id, name, author, date, single_filled, double_filled, has_final). |
| GET | /api/games/{id} |
Read the full JSON document for one game. 404 if missing. |
| PUT | /api/games/{id} |
Create or overwrite a game. Body is the game document.
Server fills in id, updated_at, and
created_at, normalizes categories and clues. |
| DELETE | /api/games/{id} |
Delete a game. 404 if missing. |
| GET | /api/games/{id}/export |
Returns the game document as a downloadable
<id>.json file
(Content-Disposition: attachment). |
| POST | /api/games/import |
Create/overwrite from an uploaded document. Body:
{"doc": {…}, "id": "override?", "overwrite": bool}.
409 if the game already exists and overwrite is false. |
Example — save and reload a game with curl
curl -X PUT http://<server>:8000/api/games/MYGAME-01 \
-H "Content-Type: application/json" \
--data-binary @my-game.json
curl http://<server>:8000/api/games/MYGAME-01
curl -OJ http://<server>:8000/api/games/MYGAME-01/export
MCP endpoint (for AI agents)
The MCP endpoint lets an agent inspect, design, and manage custom games through tool calls. Transport is MCP Streamable HTTP; the endpoint URL on this server is:
http://<server>:8000/mcp/
(Include the trailing slash — /mcp
without one gets a 307 redirect to /mcp/.)
Authentication
Every request must carry a bearer token:
Authorization: Bearer <key>
The key is generated on first server start and written to
$JPARTY_DATA_DIR/mcp_api_key (mode 0600). It is printed
to the server's stdout on every startup — a startup banner like:
========================================================================
JParty MCP API key (loaded from disk)
key: Z4m...example...9Fc
file: /app/data/mcp_api_key
rotate: rm /app/data/mcp_api_key && restart the service
usage: add header 'Authorization: Bearer Z4m...example...9Fc' to /mcp requests
========================================================================
To rotate: delete the key file and restart the service. A new key is generated on the next boot and printed to the console.
Tools exposed
| Tool | Args | Returns |
|---|---|---|
explain_schema |
none | The JSON schema + a worked example + ID rules + grid conventions + per-row dollar values. Call this first if you don't already know the format. |
list_games |
none | List of summaries. Same shape as REST
GET /api/games. |
get_game |
{id: str} |
Full document, or
{ok: false, error: …} if not found / id invalid. |
save_game |
{doc: <game-document>} |
{ok: true, game: <summary>} on success,
{ok: false, error: "…"} on validation failure. |
delete_game |
{id: str} |
{ok: true, deleted: id} or
{ok: false, error: "…"}. |
Example — Claude-compatible client
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
import httpx2
http = httpx2.AsyncClient(headers={"Authorization": f"Bearer {API_KEY}"})
async with streamable_http_client("http://host:8000/mcp/", http_client=http) as (r, w, _):
async with ClientSession(r, w) as session:
await session.initialize()
schema = await session.call_tool("explain_schema", {})
# build a game from `schema`, then:
await session.call_tool("save_game", {"doc": {...}})
Game JSON schema
This is the exact structure the server accepts and returns. Missing fields are padded (categories → empty strings, clues → empty list, final → empty strings) so partial drafts are allowed.
{
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "Unique game identifier. [A-Za-z0-9_-]{1,32}. Must NOT be a pure 1-6 digit number (reserved for J-Archive)."
},
"name": {
"type": "string",
"description": "Display name shown on the host page."
},
"author": {
"type": "string"
},
"date": {
"type": "string",
"description": "Free-form date or season label."
},
"comments": {
"type": "string"
},
"single": {
"type": "object",
"description": "The Jeopardy round (clue values $200-$1000).",
"properties": {
"categories": {
"type": "array",
"minItems": 6,
"maxItems": 6,
"items": {
"type": "string"
},
"description": "6 category headers, left to right."
},
"clues": {
"type": "array",
"items": {
"type": "object",
"required": [
"col",
"row",
"text",
"answer"
],
"properties": {
"col": {
"type": "integer",
"minimum": 0,
"maximum": 5,
"description": "Column 0-5 (matches categories)."
},
"row": {
"type": "integer",
"minimum": 0,
"maximum": 4,
"description": "Row 0-4 (0=$200, 4=$1000 in single)."
},
"text": {
"type": "string",
"description": "Clue shown to players."
},
"answer": {
"type": "string",
"description": "Correct response the host reveals."
},
"dd": {
"type": "boolean",
"default": false,
"description": "Daily Double flag. The engine re-rolls DD placements at every game start, so this value is ignored at play time."
}
}
}
}
}
},
"double": {
"type": "object",
"description": "The Double Jeopardy round (clue values $400-$2000).",
"properties": {
"categories": {
"type": "array",
"minItems": 6,
"maxItems": 6,
"items": {
"type": "string"
}
},
"clues": {
"type": "array",
"items": {
"$ref": "#/properties/single/properties/clues/items"
}
}
}
},
"final": {
"type": "object",
"description": "Final Jeopardy (one clue).",
"properties": {
"category": {
"type": "string"
},
"text": {
"type": "string"
},
"answer": {
"type": "string"
}
}
}
}
}
Notes
- Daily Doubles (
dd) are re-rolled at game-start by the engine (1 in Single, 2 in Double) on random cells with actual clue content. Theddflag stored on a clue is ignored at play time. - A clue with both
textandanswerempty is a placeholder (unrevealed/unfilled cell); the host screen shows it crossed out. - A game is playable once it has 30 real clues in each of
singleanddouble, plus a non-emptyfinal.textandfinal.answer. Anything less is a draft — saveable and listable, but the host's custom-game picker disables it.
Example document
This is what explain_schema returns under example:
{
"id": "SAMPLE-GAME",
"name": "Sample Trivia Night",
"author": "AI agent",
"date": "2026-12-02",
"comments": "A minimal example \u2014 one clue per round + Final.",
"single": {
"categories": [
"SCIENCE",
"HISTORY",
"MOVIES",
"MUSIC",
"FOOD",
"SPORTS"
],
"clues": [
{
"col": 0,
"row": 0,
"text": "Chemical formula for water.",
"answer": "What is H2O?"
},
{
"col": 1,
"row": 2,
"text": "Year the Berlin Wall fell.",
"answer": "What is 1989?"
}
]
},
"double": {
"categories": [
"GEOGRAPHY",
"LIT",
"TECH",
"ART",
"ANIMALS",
"MYTHOLOGY"
],
"clues": [
{
"col": 2,
"row": 1,
"text": "Protocol that powers the web.",
"answer": "What is HTTP?"
}
]
},
"final": {
"category": "US HISTORY",
"text": "The only U.S. president to resign from office.",
"answer": "Who was Richard Nixon?"
}
}