ttt_new_game
Create a new Tic-Tac-Toe game where X moves first. Optionally name the players to identify each side.
Instructions
Start a fresh Tic-Tac-Toe game. X always moves first. Optionally name the players so roles are explicit in every response.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| player_x_name | No | Name for the X player (e.g. 'Claude', 'Human'). Defaults to 'X'. | X |
| player_o_name | No | Name for the O player (e.g. 'Human', 'Claude'). Defaults to 'O'. | O |
Implementation Reference
- src/games/tictactoe.ts:113-140 (registration)Registration of the 'ttt_new_game' tool via server.tool() on line 114. The schema, handler, and registration are all inline in this single call.
export function registerTicTacToeTools(server: McpServer): void { server.tool( "ttt_new_game", "Start a fresh Tic-Tac-Toe game. X always moves first. Optionally name the players so roles are explicit in every response.", { player_x_name: z .string() .optional() .default("X") .describe("Name for the X player (e.g. 'Claude', 'Human'). Defaults to 'X'."), player_o_name: z .string() .optional() .default("O") .describe("Name for the O player (e.g. 'Human', 'Claude'). Defaults to 'O'."), }, async ({ player_x_name, player_o_name }) => ({ content: [ { type: "text", text: ((): string => { game = newGameState(player_x_name ?? "X", player_o_name ?? "O"); return `New Tic-Tac-Toe game started.\n\n${renderState(game)}`; })(), }, ], }) ); - src/games/tictactoe.ts:117-128 (schema)Input schema for ttt_new_game: optional player_x_name and player_o_name with defaults and descriptions.
{ player_x_name: z .string() .optional() .default("X") .describe("Name for the X player (e.g. 'Claude', 'Human'). Defaults to 'X'."), player_o_name: z .string() .optional() .default("O") .describe("Name for the O player (e.g. 'Human', 'Claude'). Defaults to 'O'."), }, - src/games/tictactoe.ts:129-139 (handler)Handler function that creates a new game state via newGameState() and returns rendered text output.
async ({ player_x_name, player_o_name }) => ({ content: [ { type: "text", text: ((): string => { game = newGameState(player_x_name ?? "X", player_o_name ?? "O"); return `New Tic-Tac-Toe game started.\n\n${renderState(game)}`; })(), }, ], }) - src/games/tictactoe.ts:22-36 (helper)Helper function newGameState() that initializes a fresh GameState object with empty board, default status, and player names.
function newGameState(playerX: string, playerO: string): GameState { return { board: [ [null, null, null], [null, null, null], [null, null, null], ], currentPlayer: "X", status: "in_progress", moveCount: 0, winningLine: null, playerX, playerO, }; } - src/games/tictactoe.ts:20-21 (helper)Module-level in-memory game state variable, initialized with default call to newGameState().
let game: GameState = newGameState("X", "O");