A Model Context Protocol (MCP) server that enables AI assistants to play tic-tac-toe through standardized tool interfaces. Perfect for demonstrating AI-human collaboration and MCP integration. This project implements a complete tic-tac-toe game as an MCP server, allowing AI assistants like Claude to: - Create and manage multiple game sessions - Make strategic moves and analyze positions - Provide
Add this skill
npx mdskills install tomholford/mcp-tic-tac-toeWell-documented MCP server with 8 useful tools for tic-tac-toe gameplay and multiple transport options.
1# MCP Tic-Tac-Toe23A Model Context Protocol (MCP) server that enables AI assistants to play tic-tac-toe through standardized tool interfaces. Perfect for demonstrating AI-human collaboration and MCP integration.4567## Overview89This project implements a complete tic-tac-toe game as an MCP server, allowing AI assistants like Claude to:10- Create and manage multiple game sessions11- Make strategic moves and analyze positions12- Provide game commentary and suggestions13- Play against humans or other AIs1415## Quick Start1617### Prerequisites18- Go 1.19+ installed19- Claude Code or other MCP-compatible client2021### Installation22```bash23git clone https://github.com/tomholford/mcp-tic-tac-toe24cd mcp-tic-tac-toe25go mod tidy26go build -o bin/server cmd/server.go27```2829### Basic Usage30```bash31# Start MCP server (stdio transport)32./bin/server3334# Or specify transport method35./bin/server -transport=sse -addr=:808036```3738## MCP Configuration3940### Claude Code Setup41421. **Build the server:**43 ```bash44 go build -o bin/server cmd/server.go45 ```46472. **Add to your MCP configuration:**4849 Create or edit your MCP configuration file:50 ```bash51 # For macOS/Linux52 ~/.config/claude-code/mcp_servers.json5354 # For Windows55 %APPDATA%\claude-code\mcp_servers.json56 ```57583. **Add the server configuration:**59 ```json60 {61 "mcpServers": {62 "tic-tac-toe": {63 "command": "/full/path/to/mcp-tic-tac-toe/bin/server",64 "args": ["-transport=stdio"],65 "env": {}66 }67 }68 }69 ```70714. **Restart Claude Code** and the tic-tac-toe tools will be available.72c73### Claude Desktop7475```json76"tic-tac-toe": {77 "command": "/full/path/to/mcp-tic-tac-toe/bin/server",78 "args": [""]79}80```8182## Available MCP Tools8384The server exposes 8 tools for complete game management:8586### Game Management87- **`new_game`** - Create a new tic-tac-toe game88 - Optional: `game_id` (string) - Custom game identifier89 - Returns: Game ID, starting player, initial board9091- **`list_games`** - Show all active game sessions92 - Returns: List of active game IDs9394- **`reset_game`** - Reset a game to initial state95 - Required: `game_id` (string)96 - Returns: Confirmation and fresh board9798### Gameplay99- **`make_move`** - Execute a move on the board100 - Required: `game_id` (string), `position` (A1-C3), `player` (X/O)101 - Returns: Updated board, game status, next player102103- **`get_board`** - Get current board state104 - Required: `game_id` (string)105 - Returns: Board display, current player, move count106107- **`get_available_moves`** - List all valid moves108 - Required: `game_id` (string)109 - Returns: Available positions for current player110111### Analysis112- **`get_status`** - Check game status and winner113 - Required: `game_id` (string)114 - Returns: Game status (ongoing/won/draw), winner if applicable115116- **`analyze_position`** - Get strategic analysis117 - Required: `game_id` (string)118 - Returns: Position analysis and board state119120## Usage Examples121122### Start a New Game123```124AI: Use the new_game tool125→ New game created with ID: game-a1b2c3d4126 Starting player: X127 Initial board:128 A B C129 1 · · ·130 2 · · ·131 3 · · ·132```133134### Make Strategic Moves135```136Human: I'll take the center137AI: Use make_move tool with {"game_id": "game-a1b2c3d4", "position": "B2", "player": "X"}138139AI: Let me analyze the position first140AI: Use analyze_position tool → Shows current state and opportunities141142AI: I'll take a corner for strategic advantage143AI: Use make_move tool with {"game_id": "game-a1b2c3d4", "position": "A1", "player": "O"}144```145146### Get Game Status147```148AI: Use get_status tool → Game Status: Ongoing, Current player: X, Move count: 2149AI: Use get_available_moves tool → Available moves (7): A2, A3, B1, B3, C1, C2, C3150```151152## Transport Options153154The server supports three transport methods:155156### 1. Stdio (Default)157Best for local MCP clients like Claude Code:158```bash159./bin/server -transport=stdio160```161162### 2. Server-Sent Events (SSE)163For web applications and real-time updates:164```bash165./bin/server -transport=sse -addr=:8080166```167168### 3. Streamable HTTP169For traditional HTTP integrations:170```bash171./bin/server -transport=http -addr=:8080172```173174## Development175176### Project Structure177```178mcp-tic-tac-toe/179├── cmd/180│ ├── server.go # MCP server main entry point181│ └── demo.go # Game logic demonstration182├── game/ # Core tic-tac-toe logic183│ ├── types.go # Game data structures184│ ├── engine.go # Game rules and validation185│ └── engine_test.go # Game logic tests186├── server/ # MCP server implementation187│ ├── server.go # MCP server setup and tools188│ ├── handlers.go # Tool request handlers189│ └── server_test.go # MCP integration tests190└── bin/ # Built executables191```192193### Running Tests194```bash195# Test all packages196go test ./game ./server -v197198# Test specific functionality199go test ./game -run TestWinConditions200go test ./server -run TestMakeMoveTool201```202203### Building from Source204```bash205# Build server206go build -o bin/server cmd/server.go207208# Build demo209go build -o bin/demo cmd/demo.go210211# Run demo (no MCP required)212./bin/demo213```214215## Resources216217- [MCP Specification](https://modelcontextprotocol.io/) - Official MCP documentation218- [mcp-go Library](https://github.com/mark3labs/mcp-go) - Go MCP implementation used in this project
Full transparency — inspect the skill content before installing.