A Model Context Protocol (MCP) server that provides an interactive blackjack game experience using MCP-UI. This server exposes blackjack game functionality through MCP tools and provides a web-based UI for playing the game.
- 🃏 Full Blackjack Game: Complete blackjack implementation with standard rules
- 🔧 MCP Tools: Blackjack game actions exposed as MCP tools
- 🎮 Interactive UI: React-based web interface using MCP-UI
- 📱 Responsive Design: Mobile-friendly interface that scales appropriately
- 🎨 Realistic Cards: Beautiful card designs with gradients and shadows
- 💰 Game State Management: Persistent game state and money tracking
- ⚡ Real-time Updates: Live game state synchronization
This MCP server is built using a full-stack React Router application with integrated MCP capabilities:
- MCP Tools (
src/tools/): Game actions exposed as MCP tools for external clients - UI Routes (
src/ui/routes/): React Router components for the web interface - Game Engine (
src/lib/game.ts): Core blackjack game logic and state management - MCP Framework (
src/framework/): Custom MCP server implementation with Express integration
blackjack-new-game: Start a new blackjack gameblackjack-hit: Hit (take another card)blackjack-stand: Stand (end turn)blackjack-double: Double downblackjack-split: Split pairsblackjack-surrender: Surrender handblackjack-take-insurance: Take insurance betblackjack-decline-insurance: Decline insurance
- Node.js 18+
- npm or pnpm
Install the dependencies:
npm installStart the development server:
npm run devThe server will be available at:
- Web UI:
http://localhost:5173/game/:id - MCP endpoint:
http://localhost:5173/mcp
Create a production build:
npm run buildStart the production server:
npm run startnpm run dev- Start development server with HMRnpm run build- Create production buildnpm run start- Run production servernpm run typecheck- Run TypeScript type checkingnpm run lint- Run ESLint and Prettier checksnpm run format- Format code with Prettier
- Navigate to
http://localhost:5173 - Click "Deal Cards" to start a new game
- Use the action buttons to play (Hit, Stand, Double, etc.)
- Game state persists across sessions
The server exposes MCP tools that can be consumed by MCP clients:
// Example MCP tool call
{
"method": "tools/call",
"params": {
"name": "blackjack-new-game",
"arguments": {
"bet": 10
}
}
}- Standard blackjack rules apply
- Dealer stands on 17
- Blackjack pays 3:2
- Insurance pays 2:1
- Double down allowed on any first two cards
- Split allowed on pairs
- Surrender allowed
src/
├── framework/ # Custom MCP framework
│ ├── mcp-server.ts # MCP server implementation
│ └── middleware.ts # Express middleware integration
├── lib/ # Utility libraries
│ ├── game.ts # Core blackjack game logic
│ ├── db.ts # Game state persistence
│ └── shell.ts # Shell execution utilities
├── tools/ # MCP tools definitions
│ ├── index.ts # Tool exports
│ └── blackjack.ts # Blackjack game tools
└── ui/ # React Router frontend
├── routes/ # Route components
│ └── blackjack.tsx # Main game interface
└── welcome/ # Welcome page assets
Build and run using Docker:
docker build -t blackjack-mcp .
docker run -p 3000:3000 blackjack-mcpThe containerized application can be deployed to any platform supporting Docker:
- AWS ECS
- Google Cloud Run
- Azure Container Apps
- Fly.io
- Railway
PORT- Server port (default: 3000 in production, 5173 in development)NODE_ENV- Environment mode
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting:
npm run lint && npm run typecheck - Submit a pull request
Apache 2.0 License - see LICENSE file for details.
Built with ❤️ using React Router, MCP, and the engine-blackjack library.