Get the FREE Ultimate OpenClaw Setup Guide →

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.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Clone the repository:
git clone <repository-url>
cd <repo-directory>
  1. Install dependencies at the monorepo root:
npm install
  1. Build the shared package first (required for development and server interactions):
npm run build --workspace=shared
  1. Build the MCP server (optional if you want to run from source after changes):
npm run build --workspace=mcp-server
  1. 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)
  1. 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

Sponsor this space

Reach thousands of developers