A real-time multiplayer quiz game platform with an AI-powered MCP (Model Context Protocol) server that lets AI assistants create, manage, and play quiz games.
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ React Client │────▶│ Game Server │────▶│ Cosmos DB │
│ (Vite + React) │ │ (Express+Socket) │ │ (NoSQL/Serverless)
└──────────────────┘ └──────────────────┘ └──────────────────┘
▲
│ Socket.io proxy
┌──────────────────┐
│ MCP Server │
│ (AI integration) │
└──────────────────┘
| Component | Description | Port |
|---|---|---|
| client/ | React SPA with Tailwind CSS — quiz creation, hosting, and gameplay UI | 5173 (dev) |
| server/ | Express REST API + Socket.io — quiz CRUD, real-time game engine | 3001 |
| mcp-server/ | MCP protocol server — exposes quiz tools to AI assistants (e.g., GitHub Copilot) | 3002 |
Data is stored in Azure Cosmos DB (NoSQL, serverless). Uploaded quiz images are stored on the local filesystem (dev) or Azure Files (production).
- Node.js v20+
- Azure Cosmos DB Emulator (for local dev) or an Azure Cosmos DB account
- Azure Developer CLI (azd) (for deployment only)
From the root of the project:
npm installThis installs dependencies for all three workspaces (server, client, mcp-server) via npm workspaces.
cp .env.example .envEdit .env and set:
| Variable | Required | Description |
|---|---|---|
COSMOS_ENDPOINT |
Yes | Cosmos DB endpoint (e.g., https://localhost:8081 for emulator) |
COSMOS_KEY |
Yes (local) | Cosmos DB key. Not needed in Azure (uses managed identity). |
PORT |
No | Game server port (default: 3001) |
MCP_PORT |
No | MCP server port (default: 3002) |
GAME_SERVER_URL |
No | Public URL for Socket.io. Set to your ngrok/devtunnel URL for remote dev. |
APP_BASE_URL |
No | Public URL of the React SPA (default: http://localhost:5173) |
Tip: If you're using the Azure Cosmos DB Emulator, the default endpoint is
https://localhost:8081and the key is available from the emulator's UI.
Run the game server and client together:
npm run devThis starts:
- Game server at
http://localhost:3001(Express + Socket.io) - React client at
http://localhost:5173(Vite dev server with hot reload)
The Vite dev server proxies /api, /uploads, and /socket.io requests to the game server automatically.
In a separate terminal:
npm run dev:mcpOr run all three services at once:
npm run dev:allThe MCP server exposes tools over Streamable HTTP at http://localhost:3002/mcp. You can connect it to any MCP-compatible client (e.g., VS Code with GitHub Copilot).
Available MCP tools:
| Tool | Description |
|---|---|
show_quizzes |
Browse and manage all quizzes (interactive widget) |
get_quiz |
Get full details of a specific quiz |
create_quiz |
Create a new quiz with questions |
add_questions |
Add questions to an existing quiz |
delete_quiz |
Delete a quiz |
play_game |
Join and play a live game by PIN |
search |
Search quizzes and questions by keyword |
fetch |
Fetch details for a search result |
If you need the MCP server's widgets to work from a remote AI client:
- Start an ngrok tunnel pointing to the MCP server port:
ngrok http 3002
- Set
GAME_SERVER_URLin.envto the ngrok HTTPS URL. - Restart the MCP server.
| Script | Description |
|---|---|
npm run dev |
Start game server + client (concurrent) |
npm run dev:mcp |
Start MCP server only |
npm run dev:all |
Start all three services (concurrent) |
npm run build |
Build all workspaces for production |
npm start |
Start the production game server |
Brain Blitz deploys to Azure Container Apps using the Azure Developer CLI (azd).
- Azure Container Apps Environment — hosts both services
- Container App: server — Express + Socket.io + React SPA
- Container App: mcp-server — MCP protocol server with Socket.io proxy
- Azure Container Registry — private Docker image store
- Azure Cosmos DB (NoSQL, serverless) — quiz data with managed-identity RBAC
- Azure Storage Account (Azure Files) — persistent storage for uploaded images
- Log Analytics Workspace — centralized logging
- User-Assigned Managed Identity — used for Cosmos DB and ACR access (no keys)
-
Log in to Azure and azd:
azd auth login
-
Provision and deploy everything:
azd up
You'll be prompted for:
- Environment name — a unique name for your deployment (e.g.,
brainblitz-dev) - Azure region — where to create resources
- Entra ID settings (optional) — leave blank to skip authentication
azd upwill:- Create the resource group and all Azure resources (Bicep)
- Build Docker images for
serverandmcp-server - Push images to Azure Container Registry
- Deploy to Container Apps
- Run the post-provision hook to configure MCP server URLs
- Environment name — a unique name for your deployment (e.g.,
-
View your app:
After deployment,
azdoutputs the live URLs:SERVER_URL— the game app (React SPA)MCP_URL— the MCP server endpoint
azd deployTo delete all Azure resources:
azd downTo protect the game server with Microsoft Entra ID sign-in, pass these parameters during azd up or set them as azd environment variables:
azd env set ENTRA_CLIENT_ID <your-app-client-id>
azd env set ENTRA_TENANT_ID <your-tenant-id>
azd env set ENTRA_CLIENT_SECRET <your-client-secret>
azd upbrain-blitz/
├── client/ # React SPA (Vite + Tailwind + Radix UI)
│ └── src/
│ ├── pages/ # Route pages (Home, Create, Edit, Host, Play)
│ ├── components/ # UI components (Leaderboard, Podium, Timer, etc.)
│ └── lib/ # Socket.io client, utilities
├── server/ # Express game server
│ └── src/
│ ├── routes/ # REST API routes (quiz CRUD)
│ ├── socket/ # Socket.io event handlers (game engine)
│ ├── db.ts # Cosmos DB client
│ └── schema.ts # Data models
├── mcp-server/ # MCP protocol server
│ ├── src/
│ │ ├── tools/ # MCP tools (quiz CRUD, game, search)
│ │ ├── resources/ # MCP resources (widget HTML)
│ │ ├── server.ts # MCP server factory
│ │ ├── config.ts # Environment config
│ │ └── db.ts # Cosmos DB client (shared)
│ └── widgets-src/ # Widget source (React components → inline HTML)
├── infra/ # Azure Bicep templates
│ ├── main.bicep # Subscription-scoped entry point
│ └── resources.bicep # All Azure resources
├── hooks/
│ └── postprovision.ps1 # Post-deploy URL configuration
├── azure.yaml # AZD project definition
└── .env.example # Environment variable template
This project is provided as-is for educational and demonstration purposes.