turn-based-game
A turn-based games app built with Next.js and TypeScript that features Tic-Tac-Toe and Rock Paper Scissors games with AI opponents powered by the Model Context Protocol (MCP), offering three difficulty levels.
claude mcp add --transport stdio github-samples-turn-based-game-mcp node dist/index.js
How to use
This MCP server provides an AI opponent for the Turn-Based Games Web App. It acts as a Model Context Protocol (MCP) agent that can evaluate the current game state and generate moves for Tic-Tac-Toe and Rock Paper Scissors across different AI difficulties. The server is designed to run in stdio mode and can be integrated with MCP-compatible clients, enabling automated play, analysis, and dynamic strategy adjustments. Use the MCP tools exposed by this server to create games, make AI moves, wait for player input, and analyze ongoing games. The available tools support creating Tic-Tac-Toe instances, prompting the AI to move, creating Rock Paper Scissors games, requesting AI choices, waiting for human moves, and analyzing game scenarios. These capabilities make it easy to prototype AI opponents, test strategies, and experiment with MCP integrations in a turn-based setting.
How to install
Prerequisites:
- Node.js 18 or higher
- npm or pnpm
Installation steps:
- Clone the repository:
git clone <repository-url>
cd <repo-directory>
- Install dependencies at the monorepo root:
npm install
- Build the shared package first (required for development and server interactions):
npm run build --workspace=shared
- Build the MCP server (optional if you want to run from source after changes):
npm run build --workspace=mcp-server
- Start the development servers (web frontend and MCP server):
npm run dev --workspace=web # Web app (Next.js)
npm run dev --workspace=mcp-server # MCP server (stdio)
- If you prefer running everything from root scripts, you can use:
npm run dev # Runs web dev server
npm run dev:mcp # Runs MCP server
Notes:
- The shared package must be built before other packages can be developed or built since web and mcp-server depend on it.
Additional notes
Tips and common issues:
- Ensure the shared package is built before running the web app or MCP server to avoid missing type definitions or runtime errors.
- The MCP server runs via stdio and expects to be connected to via MCP-compatible clients. If you plan to test locally, you can connect using the provided MCP tooling in the repository or simulate a client.
- Environment variables for advanced configuration can be added under the env object in mcp_config.mcpServers[...].env, e.g., to set a debug flag or API endpoints if extended in future.
- If you modify game logic or AI strategies, re-run the appropriate build steps to reflect changes across web and server packages.
- Typical runtime traffic is low in development; for production-like scenarios, consider running the MCP server behind a process manager and ensuring the AI computation does not block the event loop.
Related MCP Servers
pluggedin-app
The Crossroads for AI Data Exchanges. A unified, self-hostable web interface for discovering, configuring, and managing Model Context Protocol (MCP) servers—bringing together AI tools, workspaces, prompts, and logs from multiple MCP sources (Claude, Cursor, etc.) under one roof.
MCPNotes
A simple note-taking MCP server for recording and managing notes with AI models.
filesystem
A Model Context Protocol (MCP) server for platform-agnostic file capabilities, including advanced search/replace and directory tree traversal
pinmeto-location
PinMeTo MCP server that enables users with authorized credentials to unlock their data
alris
Alris is an AI automation tool that transforms natural language commands into task execution.
ava
Automatically share development progress to Slack through AI. MCP-powered task reporting with privacy-first design.