Skip to main content
Glama
Vic563

Minesweeper MCP Server

by Vic563

get_board

Retrieve the current state and visual layout of a Minesweeper game board to track progress and plan moves.

Instructions

Get the current state and visual representation of a Minesweeper board

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
boardIdYesID of the board to display

Implementation Reference

  • Handler for the 'get_board' tool. Extracts boardId from input arguments, calls MinesweeperGame.getBoardDisplay(boardId), and returns the textual board display.
    case 'get_board': {
      const { boardId } = args as { boardId: string };
      const display = this.game.getBoardDisplay(boardId);
    
      return {
        content: [
          {
            type: 'text',
            text: display,
          },
        ],
      };
    }
  • src/index.ts:128-141 (registration)
    Tool registration for 'get_board' in the listTools response, including name, description, and input schema requiring a boardId string.
    {
      name: 'get_board',
      description: 'Get the current state and visual representation of a Minesweeper board',
      inputSchema: {
        type: 'object',
        properties: {
          boardId: {
            type: 'string',
            description: 'ID of the board to display',
          },
        },
        required: ['boardId'],
      },
    },
  • Core helper function getBoardDisplay that retrieves the GameBoard by ID and formats it into a human-readable ASCII art string with board info, coordinates, and symbols for cells (. hidden, F flagged, * mine, numbers, space empty).
    getBoardDisplay(boardId: string): string {
      const board = this.boards.get(boardId);
      if (!board) {
        throw new Error(`Board with id ${boardId} not found`);
      }
    
      let display = `Minesweeper Board: ${boardId}\n`;
      display += `Size: ${board.width}x${board.height}, Mines: ${board.mineCount}\n`;
      display += `Status: ${board.gameState}\n`;
      
      if (board.endTime) {
        const duration = Math.round((board.endTime - board.startTime) / 1000);
        display += `Duration: ${duration}s\n`;
      }
      
      display += '\n';
    
      // Add column numbers
      display += '   ';
      for (let x = 0; x < board.width; x++) {
        display += (x % 10).toString().padStart(2);
      }
      display += '\n';
    
      for (let y = 0; y < board.height; y++) {
        display += y.toString().padStart(2) + ' ';
        for (let x = 0; x < board.width; x++) {
          const cell = board.cells[y][x];
          let symbol = '.';
          
          if (cell.isFlagged) {
            symbol = 'F';
          } else if (cell.isRevealed) {
            if (cell.isMine) {
              symbol = '*';
            } else if (cell.neighborMines > 0) {
              symbol = cell.neighborMines.toString();
            } else {
              symbol = ' ';
            }
          }
          
          display += symbol.padStart(2);
        }
        display += '\n';
      }
    
      return display;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vic563/mindsweeper-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server