gomoku-mcp-server

junyeong-nero/gomoku-mcp-server

3.2

If you are the rightful owner of gomoku-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This document provides a comprehensive overview of setting up and running a Model Context Protocol (MCP) server, including environment setup, API key configuration, and execution instructions.

Gomoku MCP Server

A Gomoku (Five-in-a-Row) game server that enables LLMs to play through the Model Context Protocol (MCP). Features intelligent threat analysis and strategic move suggestions.

Features

  • 15x15 Standard Board: Classic Gomoku gameplay
  • MCP Tool Integration: Full game control through MCP tools
  • Threat Analysis: Detects open-fours, closed-fours, open-threes, and gap patterns
  • Move Suggestions: Priority-ranked move recommendations based on tactical analysis
  • Multi-Model Support: Works with any LLM via OpenRouter (Gemini, Grok, Kimi, etc.)
  • CLI and GUI: Both command-line and graphical interfaces
  • Two Player Mode: Watch two LLMs compete against each other

Architecture

src/
├── game/
│   ├── gomoku.py      # Core game logic
│   └── patterns.py    # Pattern detection engine
├── mcp_server/
│   └── server.py      # FastMCP server with game tools
├── prompts/
│   ├── system_prompt.py   # AI player system prompt
│   └── user_prompt.py     # Turn prompt template
├── agents.py          # LLM Agent for tool interactions
├── manager.py         # Game state coordinator
├── cli.py             # Command-line interface
└── gui.py             # Graphical interface

Installation

Environment Setup with uv

uv sync
uv pip install -e .

OpenRouter API Key

export OPENROUTER_API_KEY="YOUR_API_KEY"

Run

uv run src/cli.py   # Command-line interface (PvE or AI vs AI)
uv run src/gui.py   # Graphical interface (PvE or AI vs AI)

Two Player Mode (LLM vs LLM)

두 개의 LLM이 서로 오목을 두는 대결을 관전할 수 있습니다.

CLI에서:

uv run src/cli.py
# Select "2. Two Player 모드 (AI vs AI)"

GUI에서:

uv run src/gui.py
# Open http://localhost:8000
# Select "⚔️ AI vs AI" mode
# Choose models for Black and White
# Click "게임 시작"

How It Works

  1. The MCP server exposes game tools: set_stone, analyze_threats, get_suggested_moves, etc.
  2. The LLM agent receives the current game state and turn prompt
  3. The agent analyzes threats using analyze_threats() and gets ranked moves via get_suggested_moves()
  4. Based on priority (blocking opponent fours > creating own threats > strategic positioning), the agent places a stone
  5. The pattern detector evaluates: Open-4, Closed-4, Open-3, Closed-3, Gap patterns

Threat Priority Levels

PriorityThreat TypeDescription
10WinComplete 5-in-a-row
9Block FourStop opponent's open/closed four
8Create FourMake an open four
7Block Open-3Prevent opponent's open three
6Create Open-3Build pressure with open three
3-5StrategicCenter control, pattern extension

Sample Games

  • gemini-2.5-flash image

  • grok4-fast image

  • kimi-k2-thinking image

MCP Configuration

Add to your MCP client configuration:

{
  "mcp-gomoku": {
    "command": "uv",
    "args": [
      "--directory",
      "/path/to/gomoku-mcp-server/",
      "run",
      "src/server.py"
    ]
  }
}

Available MCP Tools

ToolDescription
restart()Reset game to initial state
visualize()Text-based board representation
get_state()Complete game state
set_stone(x, y, turn)Place a stone
get_valid_moves()List of empty positions
get_turn()Current turn status
analyze_threats()Threat analysis for both players
get_suggested_moves(count)Priority-ranked move suggestions