Skip to main content
Glama
Vic563

Minesweeper MCP Server

by Vic563

reveal_cell

Reveal a cell on a Minesweeper board to check for mines or clear safe areas. Specify board ID and coordinates to interact with the game.

Instructions

Reveal a cell on the Minesweeper board

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
boardIdYesID of the board
xYesX coordinate (column) of the cell to reveal
yYesY coordinate (row) of the cell to reveal

Implementation Reference

  • Core implementation of revealCell: validates input, handles mine revelation (loss), recursive reveal for safe cells, checks win condition, updates game state.
    revealCell(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 || cell.isFlagged) {
        return board; // Already revealed or flagged
      }
    
      if (cell.isMine) {
        // Game over
        cell.isRevealed = true;
        board.gameState = 'lost';
        board.endTime = Date.now();
        // Reveal all mines
        for (let row of board.cells) {
          for (let c of row) {
            if (c.isMine) {
              c.isRevealed = true;
            }
          }
        }
      } else {
        // Reveal cell and potentially cascade
        this.revealCellRecursive(board, x, y);
        
        // Check win condition
        if (this.checkWinCondition(board)) {
          board.gameState = 'won';
          board.endTime = Date.now();
        }
      }
    
      return board;
    }
  • Recursive helper function that reveals adjacent safe empty cells (flood fill).
    private revealCellRecursive(board: GameBoard, x: number, y: number): void {
      if (x < 0 || x >= board.width || y < 0 || y >= board.height) return;
      
      const cell = board.cells[y][x];
      if (cell.isRevealed || cell.isFlagged || cell.isMine) return;
    
      cell.isRevealed = true;
    
      // If cell has no neighboring mines, reveal all neighbors
      if (cell.neighborMines === 0) {
        for (let dy = -1; dy <= 1; dy++) {
          for (let dx = -1; dx <= 1; dx++) {
            if (dx === 0 && dy === 0) continue;
            this.revealCellRecursive(board, x + dx, y + dy);
          }
        }
      }
    }
  • Input schema definition for the reveal_cell tool, including parameters boardId, x, y.
      name: 'reveal_cell',
      description: 'Reveal 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 reveal',
            minimum: 0,
          },
          y: {
            type: 'number',
            description: 'Y coordinate (row) of the cell to reveal',
            minimum: 0,
          },
        },
        required: ['boardId', 'x', 'y'],
      },
    },
  • src/index.ts:46-166 (registration)
    Registration of tools list including reveal_cell via setRequestHandler for ListToolsRequestSchema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'create_board',
            description: 'Create a new Minesweeper board with specified dimensions and mine count',
            inputSchema: {
              type: 'object',
              properties: {
                id: {
                  type: 'string',
                  description: 'Unique identifier for the board',
                },
                width: {
                  type: 'number',
                  description: 'Width of the board (number of columns)',
                  minimum: 1,
                  maximum: 50,
                },
                height: {
                  type: 'number',
                  description: 'Height of the board (number of rows)',
                  minimum: 1,
                  maximum: 50,
                },
                mineCount: {
                  type: 'number',
                  description: 'Number of mines to place on the board',
                  minimum: 0,
                },
              },
              required: ['id', 'width', 'height', 'mineCount'],
            },
          },
          {
            name: 'reveal_cell',
            description: 'Reveal 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 reveal',
                  minimum: 0,
                },
                y: {
                  type: 'number',
                  description: 'Y coordinate (row) of the cell to reveal',
                  minimum: 0,
                },
              },
              required: ['boardId', 'x', 'y'],
            },
          },
          {
            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'],
            },
          },
          {
            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'],
            },
          },
          {
            name: 'list_boards',
            description: 'List all active Minesweeper boards',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'delete_board',
            description: 'Delete a Minesweeper board',
            inputSchema: {
              type: 'object',
              properties: {
                boardId: {
                  type: 'string',
                  description: 'ID of the board to delete',
                },
              },
              required: ['boardId'],
            },
          },
        ] as Tool[],
      };
    });
  • MCP tool call handler for reveal_cell: parses arguments, calls game.revealCell, formats response with board display and game status.
    case 'reveal_cell': {
      const { boardId, x, y } = args as {
        boardId: string;
        x: number;
        y: number;
      };
    
      const board = this.game.revealCell(boardId, x, y);
      const display = this.game.getBoardDisplay(boardId);
    
      let message = `Revealed cell at (${x}, ${y})\n\n${display}`;
      
      if (board.gameState === 'won') {
        const duration = board.endTime ? Math.round((board.endTime - board.startTime) / 1000) : 0;
        message += `\nšŸŽ‰ Congratulations! You won in ${duration} seconds!`;
      } else if (board.gameState === 'lost') {
        message += `\nšŸ’„ Game Over! You hit a mine at (${x}, ${y}).`;
      }
    
      return {
        content: [
          {
            type: 'text',
            text: message,
          },
        ],
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks critical behavioral details. It doesn't disclose that revealing a mine ends the game, that revealing a numbered cell shows adjacent mines, or that revealing an empty cell triggers cascading reveals. These are essential behavioral traits for a Minesweeper agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's perfectly front-loaded with the core action and resource, making it immediately scannable and appropriately sized for its purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a game action tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after revealing (game state changes, win/lose conditions, return values), nor does it cover error cases like invalid coordinates or completed boards. Given the complexity of Minesweeper mechanics, this leaves significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline expectation but not providing extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('reveal') and resource ('a cell on the Minesweeper board'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'flag_cell' which operates on the same resource type, missing the opportunity for full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'flag_cell' for marking mines. It also doesn't mention prerequisites such as needing an existing board (created via 'create_board') or that coordinates must be within board bounds, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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