Letting LLM Play Minesweeper via MCP

Use MCP to let an LLM play Minesweeper.

Introduction

The combination of MCP and games is exciting.

This time, I found an MCP server that lets LLMs play Minesweeper: Minesweeper MCP Server. I tried it out and had some fun with it.

Here is the record of the process.

# Environment: macOS
# Node version
node --version
v20.19.0

Note: This article was translated from my original post.

Playing Minesweeper via MCP

Overview

Here’s the overall architecture:

Overall Architecture

First, start both the Minesweeper server and the MCP server locally. The Minesweeper server exposes Minesweeper via an API and will be controlled by the MCP server.

For the MCP client, we’ll use Claude Desktop. Claude Desktop connects to the MCP server and lets Claude play Minesweeper using the provided tools.

The game screen can be viewed from your browser.

Let’s go through it step by step.

Starting the Minesweeper Server

Clone the repository and follow the guide to start the Minesweeper server:

# Clone the repo
git clone https://github.com/tonypan2/minesweeper-server.git
cd minesweeper-server

# Install and run
npm install
npm run dev

If you see output like the following, it's working:

$ npm run dev

> minesweeper-server@0.1.0 dev
> next dev --turbopack -p 5000

   ▲ Next.js 15.2.3 (Turbopack)
   - Local:        http://localhost:5000
   - Network:      http://192.168.10.102:5000

 ✓ Starting...
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

 ✓ Ready in 1022ms

Now open http://localhost:5000/view in your browser to see the Minesweeper UI screen (waiting state).

Minesweeper UI in browser (waiting)

Building the MCP Server

Next, build the MCP server.

In a different directory from the Minesweeper server, run:

# Clone the repo
git clone https://github.com/tonypan2/minesweeper-mcp-server.git
cd minesweeper-mcp-server

# Install and build
npm install
npm run build

If build/index.js is generated, the build was successful.

The MCP server is launched by the MCP client (Claude Desktop), so there’s no need to run it just yet.

Connecting Claude Desktop with MCP Server

Once setup is done, connect Claude Desktop with the MCP server.

For general instructions on how to connect Claude Desktop with MCP servers, refer to my another article:

en.bioerrorlog.work


Here’s the config file format to connect the MCP server with Claude Desktop:

{
  "mcpServers": {
    "mcp-server": {
      "command": "node",
      # Specify the build path to the MCP server
      "args": ["/path/to/minesweeper-mcp-server/build/index.js"],
      "env": {
        "DEBUG": "*"
      }
    }
  }
}


Example:

{
  "mcpServers": {
    "mcp-server": {
      "command": "node",
      "args": ["/Users/bioerrorlog/dev/mines-mcp/minesweeper-mcp-server/build/index.js"],
      "env": {
        "DEBUG": "*"
      }
    }
  }
}


Once connected successfully, you’ll see the Minesweeper tools from the MCP server accessible via the hammer icon.

Claude Desktop connected to Minesweeper MCP tools

Letting Claude Play Minesweeper

Now it’s time to let Claude play Minesweeper.

Keep the Minesweeper UI open in your browser (http://localhost:5000/view) and give Claude a prompt like the following in Claude Desktop:

Prompt example:

Start a new game of Minesweeper. Try your best to keep playing until you have flagged all mines. Remember that the coordinates are 0-indexed.

This starts the game via MCP, and Claude begins playing Minesweeper.

Here’s what it looks like:

Starting Minesweeper via 'start_game' tool

Claude playing Minesweeper

Game over

Here’s a video of it in action:

After several trials, it seems Claude isn’t too skilled at this kind of game. I didn’t witness any successful completions when left to the model alone.

It might be more interesting with prompt tweaks or some human interaction.

Conclusion

That’s it for letting Claude play Minesweeper via MCP.

As I mentioned in the beginning, the combination of MCP and games holds great potential. Looking forward to trying more experiments.

Hope this was helpful to someone.

[Related Articles]

en.bioerrorlog.work

en.bioerrorlog.work

References