{"openapi":"3.1.0","info":{"title":"Tower Defense API","version":"0.1.0","description":"A real, stateless, playable simplified tower-defense engine: a fixed path grid, real placement validation with exact gold-cost deduction, real tower-range-vs-enemy-position damage computation, enemy HP/death/reward tracking, and wave-completion/loss detection. Every tool call takes the full game state and returns the new state; nothing is stored server-side.\n\nEvery operation is read-only or compute-only. The same tools are available over MCP (streamable HTTP) at https://towerdefense.connectorbay.com/mcp.","contact":{"name":"Unify Dynamics LLC","email":"hr@unifydynamics.com","url":"https://connectorbay.com/towerdefense/docs"},"termsOfService":"https://connectorbay.com/towerdefense/terms"},"servers":[{"url":"https://towerdefense.connectorbay.com"}],"externalDocs":{"url":"https://connectorbay.com/towerdefense/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":"Starts a fresh game: builds the fixed zig-zag path and returns the initial state (no towers","description":"Starts a fresh game: builds the fixed zig-zag path and returns the initial state (no towers\n    placed yet, wave_number 0). Use for \"let's play tower defense\", \"start a new game\".","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"width":{"default":12,"description":"Grid width in cells.","maximum":24,"minimum":6,"title":"Width","type":"integer"},"height":{"default":8,"description":"Grid height in cells.","maximum":18,"minimum":5,"title":"Height","type":"integer"},"gold":{"default":150,"description":"Starting gold.","maximum":10000,"minimum":0,"title":"Gold","type":"integer"},"lives":{"default":20,"description":"Starting lives.","maximum":99,"minimum":1,"title":"Lives","type":"integer"}},"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/place_tower":{"post":{"operationId":"place_tower","summary":"Validates and places one tower, deducting its exact gold cost. Rejected (state unchanged,","description":"Validates and places one tower, deducting its exact gold cost. Rejected (state unchanged,\n    placed: false, tower: null, with a message explaining why) if the position is off-grid, on the\n    enemy path, already occupied, or unaffordable. The tool call itself still succeeds (ok: true) —\n    a rejection is a normal game outcome, not an error. Use for \"place an arrow tower at 3,2\",\n    \"build a cannon there\".","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"The current game state, exactly as returned by new_game/place_tower/advance_wave.","title":"State","type":"object"},"position":{"description":"[x, y] grid cell to build on.","examples":[[3,2]],"items":{"type":"integer"},"title":"Position","type":"array"},"type":{"default":"arrow","description":"'arrow' or 'cannon'.","title":"Type","type":"string"}},"required":["state","position"],"title":"place_towerArguments","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/advance_wave":{"post":{"operationId":"advance_wave","summary":"Spawns the next wave and simulates real per-tick combat to completion: every enemy moves","description":"Spawns the next wave and simulates real per-tick combat to completion: every enemy moves\n    along the path, every tower deals real range-checked damage each tick, kills award gold, and\n    an enemy reaching the end costs one life. Returns the new state plus wave_number, kills,\n    escaped, gold_earned, ticks_run, and status (\"in_progress\" or \"loss\"). Use for \"send the next\n    wave\", \"advance\".","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"The current game state, exactly as returned by new_game/place_tower/advance_wave.","title":"State","type":"object"}},"required":["state"],"title":"advance_waveArguments","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":{"post":{"operationId":"render","summary":"An ASCII view of the grid: '.' path, 'A'/'C' tower type, a digit for stacked enemies on a","description":"An ASCII view of the grid: '.' path, 'A'/'C' tower type, a digit for stacked enemies on a\n    cell, blank for empty buildable ground. Use for \"show me the board\".","tags":["tools"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"state":{"additionalProperties":true,"description":"The current game state, exactly as returned by new_game/place_tower/advance_wave.","title":"State","type":"object"}},"required":["state"],"title":"renderArguments","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}}}}