{"openapi":"3.1.0","info":{"title":"Nim Play API","version":"0.1.0","description":"A fully local, playable Nim engine (multi-pile, Marienbad-style preset, misere play) with a provably optimal nim-sum AI opponent. Stateless: the caller holds the game state between calls.\n\nEvery operation is read-only or compute-only. The same tools are available over MCP (streamable HTTP) at https://nimplay.connectorbay.com/mcp.","contact":{"name":"Unify Dynamics LLC","email":"hr@unifydynamics.com","url":"https://connectorbay.com/nimplay/docs"},"termsOfService":"https://connectorbay.com/nimplay/terms"},"servers":[{"url":"https://nimplay.connectorbay.com"}],"externalDocs":{"url":"https://connectorbay.com/nimplay/docs"},"security":[{},{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Optional. A Pro API key raises rate limits; no credentials are required."}},"schemas":{"Error":{"type":"object","properties":{"ok":{"const":false},"error":{"type":"object"}}}}},"paths":{"/v1/tools/new_game":{"post":{"operationId":"new_game","summary":"Start a new Nim game and return its initial state. Pass explicit `piles`, or let one of `num_piles`/","description":"Start a new Nim game and return its initial state. Pass explicit `piles`, or let one of `num_piles`/\n    `max_stones` or a named `preset` (marienbad = 1/3/5/7, twin_piles = 7/7, single_pile = 13) generate the\n    start. `variant` picks normal or misere play. Use for \"let's play Nim\", \"start a Marienbad game\",\n    \"new misere Nim game with 4 piles\".","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"piles":{"anyOf":[{"items":{"type":"integer"},"type":"array"},{"type":"null"}],"default":null,"description":"Explicit starting pile sizes, e.g. [3, 5, 7]. Omit to use num_piles/max_stones or preset.","title":"Piles"},"num_piles":{"default":3,"description":"Number of piles for a randomly generated start (ignored if piles or preset given).","maximum":10,"minimum":1,"title":"Num Piles","type":"integer"},"max_stones":{"default":10,"description":"Max stones per pile for a randomly generated start.","maximum":50,"minimum":1,"title":"Max Stones","type":"integer"},"preset":{"anyOf":[{"type":"string"},{"type":"null"}],"default":null,"description":"A named starting position instead of piles: 'marienbad', 'twin_piles', or 'single_pile'.","title":"Preset"},"variant":{"default":"normal","description":"'normal' (last to move wins) or 'misere' (last to move loses).","title":"Variant","type":"string"},"first_player":{"default":"human","description":"Who moves first: 'human' or 'ai'.","title":"First Player","type":"string"}},"title":"new_gameArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/make_move":{"post":{"operationId":"make_move","summary":"Apply the human player's move: remove `remove` objects from pile `pile`. Returns the new state and a","description":"Apply the human player's move: remove `remove` objects from pile `pile`. Returns the new state and a\n    status (in_progress / win / loss / invalid_move) from the human's perspective.","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"Current game state, exactly as returned by a previous call.","title":"State","type":"object"},"pile":{"description":"Index of the pile to remove from.","minimum":0,"title":"Pile","type":"integer"},"remove":{"description":"How many objects to remove from that pile.","minimum":1,"title":"Remove","type":"integer"}},"required":["state","pile","remove"],"title":"make_moveArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/ai_move":{"post":{"operationId":"ai_move","summary":"Compute AND apply the AI's move. 'optimal' uses real nim-sum theory (Bouton's theorem for normal","description":"Compute AND apply the AI's move. 'optimal' uses real nim-sum theory (Bouton's theorem for normal\n    play, the misere endgame theorem for misere play) — it is mathematically guaranteed to win from any\n    position that is a theoretical win for the mover. 'easy' picks a uniformly random legal move.","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"Current game state, exactly as returned by a previous call.","title":"State","type":"object"},"difficulty":{"default":"optimal","description":"'optimal' (provably correct nim-sum/misere strategy) or 'easy' (random legal move).","title":"Difficulty","type":"string"}},"required":["state"],"title":"ai_moveArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/get_valid_moves":{"post":{"operationId":"get_valid_moves","summary":"List legal moves for the current position: per-pile remove ranges, plus a full enumerated move list","description":"List legal moves for the current position: per-pile remove ranges, plus a full enumerated move list\n    when the position is small enough (<=80 total objects).","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"Current game state, exactly as returned by a previous call.","title":"State","type":"object"}},"required":["state"],"title":"get_valid_movesArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/render_board":{"post":{"operationId":"render_board","summary":"Render the current position as a human-readable ASCII board.","description":"Render the current position as a human-readable ASCII board.","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"Current game state, exactly as returned by a previous call.","title":"State","type":"object"}},"required":["state"],"title":"render_boardArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/analyze_position":{"post":{"operationId":"analyze_position","summary":"Report the nim-sum of the current position and whether the player to move is in a mathematically","description":"Report the nim-sum of the current position and whether the player to move is in a mathematically\n    proven winning or losing position against perfect play. Transparent look at the same theory ai_move\n    uses to choose its moves.","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"Current game state, exactly as returned by a previous call.","title":"State","type":"object"}},"required":["state"],"title":"analyze_positionArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/rules_info":{"post":{"operationId":"rules_info","summary":"Explain how Nim is played and the optimal (nim-sum) strategy for the given variant.","description":"Explain how Nim is played and the optimal (nim-sum) strategy for the given variant.","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"variant":{"default":"normal","description":"'normal' or 'misere'.","title":"Variant","type":"string"}},"title":"rules_infoArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}},"/v1/tools/list_presets":{"post":{"operationId":"list_presets","summary":"List the built-in named starting positions and the available variants.","description":"List the built-in named starting positions and the available variants.","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{},"title":"list_presetsArguments","type":"object"}}}},"responses":{"200":{"description":"Tool result. `ok: true` on success; `ok: false` with a structured `error` (provider_unavailable, upstream_error, bad_input) when the tool could not answer.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"description":"Arguments failed validation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-read-only":true}}}}