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:
git clone https://github.com/tomholford/mcp-tic-tac-toe
cd mcp-tic-tac-toe
go mod tidy
go build -o bin/server cmd/server.go
# Start MCP server (stdio transport)
./bin/server
# Or specify transport method
./bin/server -transport=sse -addr=:8080
Build the server:
go build -o bin/server cmd/server.go
Add to your MCP configuration:
Create or edit your MCP configuration file:
# For macOS/Linux
~/.config/claude-code/mcp_servers.json
# For Windows
%APPDATA%\claude-code\mcp_servers.json
Add the server configuration:
{
"mcpServers": {
"tic-tac-toe": {
"command": "/full/path/to/mcp-tic-tac-toe/bin/server",
"args": ["-transport=stdio"],
"env": {}
}
}
}
Restart Claude Code and the tic-tac-toe tools will be available. c
"tic-tac-toe": {
"command": "/full/path/to/mcp-tic-tac-toe/bin/server",
"args": [""]
}
The server exposes 8 tools for complete game management:
new_game
- Create a new tic-tac-toe game
game_id
(string) - Custom game identifierlist_games
- Show all active game sessions
reset_game
- Reset a game to initial state
game_id
(string)make_move
- Execute a move on the board
game_id
(string), position
(A1-C3), player
(X/O)get_board
- Get current board state
game_id
(string)get_available_moves
- List all valid moves
game_id
(string)get_status
- Check game status and winner
game_id
(string)analyze_position
- Get strategic analysis
game_id
(string)AI: Use the new_game tool
โ New game created with ID: game-a1b2c3d4
Starting player: X
Initial board:
A B C
1 ยท ยท ยท
2 ยท ยท ยท
3 ยท ยท ยท
Human: I'll take the center
AI: Use make_move tool with {"game_id": "game-a1b2c3d4", "position": "B2", "player": "X"}
AI: Let me analyze the position first
AI: Use analyze_position tool โ Shows current state and opportunities
AI: I'll take a corner for strategic advantage
AI: Use make_move tool with {"game_id": "game-a1b2c3d4", "position": "A1", "player": "O"}
AI: Use get_status tool โ Game Status: Ongoing, Current player: X, Move count: 2
AI: Use get_available_moves tool โ Available moves (7): A2, A3, B1, B3, C1, C2, C3
The server supports three transport methods:
Best for local MCP clients like Claude Code:
./bin/server -transport=stdio
For web applications and real-time updates:
./bin/server -transport=sse -addr=:8080
For traditional HTTP integrations:
./bin/server -transport=http -addr=:8080
mcp-tic-tac-toe/
โโโ cmd/
โ โโโ server.go # MCP server main entry point
โ โโโ demo.go # Game logic demonstration
โโโ game/ # Core tic-tac-toe logic
โ โโโ types.go # Game data structures
โ โโโ engine.go # Game rules and validation
โ โโโ engine_test.go # Game logic tests
โโโ server/ # MCP server implementation
โ โโโ server.go # MCP server setup and tools
โ โโโ handlers.go # Tool request handlers
โ โโโ server_test.go # MCP integration tests
โโโ bin/ # Built executables
# Test all packages
go test ./game ./server -v
# Test specific functionality
go test ./game -run TestWinConditions
go test ./server -run TestMakeMoveTool
# Build server
go build -o bin/server cmd/server.go
# Build demo
go build -o bin/demo cmd/demo.go
# Run demo (no MCP required)
./bin/demo