flag_cell
Mark or clear flags on Minesweeper board cells to identify suspected mine locations and prevent accidental clicks during gameplay.
Instructions
Flag or unflag a cell on the Minesweeper board
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| boardId | Yes | ID of the board | |
| x | Yes | X coordinate (column) of the cell to flag | |
| y | Yes | Y coordinate (row) of the cell to flag |
Implementation Reference
- src/minesweeper.ts:187-206 (handler)Core handler function that toggles the flag status on the specified cell, with validation for board existence, game state, coordinates, and revealed cells.flagCell(boardId: string, x: number, y: number): GameBoard { const board = this.boards.get(boardId); if (!board) { throw new Error(`Board with id ${boardId} not found`); } if (board.gameState !== 'playing') { throw new Error('Game is already finished'); } if (x < 0 || x >= board.width || y < 0 || y >= board.height) { throw new Error('Invalid cell coordinates'); } const cell = board.cells[y][x]; if (cell.isRevealed) { throw new Error('Cannot flag a revealed cell'); } cell.isFlagged = !cell.isFlagged; return board; }
- src/index.ts:223-241 (handler)MCP server tool handler for 'flag_cell' that extracts arguments, calls the game flagCell method, retrieves the board display, and formats the response.case 'flag_cell': { const { boardId, x, y } = args as { boardId: string; x: number; y: number; }; this.game.flagCell(boardId, x, y); const display = this.game.getBoardDisplay(boardId); return { content: [ { type: 'text', text: `Toggled flag at cell (${x}, ${y})\n\n${display}`, }, ], }; }
- src/index.ts:104-127 (registration)Registration of the 'flag_cell' tool in the MCP server's listTools handler, including name, description, and input schema.{ name: 'flag_cell', description: 'Flag or unflag a cell on the Minesweeper board', inputSchema: { type: 'object', properties: { boardId: { type: 'string', description: 'ID of the board', }, x: { type: 'number', description: 'X coordinate (column) of the cell to flag', minimum: 0, }, y: { type: 'number', description: 'Y coordinate (row) of the cell to flag', minimum: 0, }, }, required: ['boardId', 'x', 'y'], }, },
- src/index.ts:107-126 (schema)Input schema definition for the 'flag_cell' tool validating boardId, x, and y parameters.inputSchema: { type: 'object', properties: { boardId: { type: 'string', description: 'ID of the board', }, x: { type: 'number', description: 'X coordinate (column) of the cell to flag', minimum: 0, }, y: { type: 'number', description: 'Y coordinate (row) of the cell to flag', minimum: 0, }, }, required: ['boardId', 'x', 'y'], },