Blackjack MCP Server

Blackjack MCP Server

Provides an interactive blackjack game with standard rules via MCP tools and a web UI, enabling actions like hit, stand, and double down.

Category
Visit Server

README

Blackjack MCP Server

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.

Features

  • šŸƒ 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

Architecture

This MCP server is built using a full-stack React Router application with integrated MCP capabilities:

Key Components

  • 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

MCP Tools Available

  • blackjack-new-game: Start a new blackjack game
  • blackjack-hit: Hit (take another card)
  • blackjack-stand: Stand (end turn)
  • blackjack-double: Double down
  • blackjack-split: Split pairs
  • blackjack-surrender: Surrender hand
  • blackjack-take-insurance: Take insurance bet
  • blackjack-decline-insurance: Decline insurance

Getting Started

Prerequisites

  • Node.js 18+
  • npm or pnpm

Installation

Install the dependencies:

npm install

Development

Start the development server:

npm run dev

The server will be available at:

  • Web UI: http://localhost:5173/game/:id
  • MCP endpoint: http://localhost:5173/mcp

Building for Production

Create a production build:

npm run build

Start the production server:

npm run start

Development Commands

  • npm run dev - Start development server with HMR
  • npm run build - Create production build
  • npm run start - Run production server
  • npm run typecheck - Run TypeScript type checking
  • npm run lint - Run ESLint and Prettier checks
  • npm run format - Format code with Prettier

Usage

As a Web Application

  1. Navigate to http://localhost:5173
  2. Click "Deal Cards" to start a new game
  3. Use the action buttons to play (Hit, Stand, Double, etc.)
  4. Game state persists across sessions

As an MCP Server

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
    }
  }
}

Game Rules

  • 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

Project Structure

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

Deployment

Docker Deployment

Build and run using Docker:

docker build -t blackjack-mcp .
docker run -p 3000:3000 blackjack-mcp

The containerized application can be deployed to any platform supporting Docker:

  • AWS ECS
  • Google Cloud Run
  • Azure Container Apps
  • Fly.io
  • Railway

Environment Variables

  • PORT - Server port (default: 3000 in production, 5173 in development)
  • NODE_ENV - Environment mode

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting: npm run lint && npm run typecheck
  5. Submit a pull request

License

Apache 2.0 License - see LICENSE file for details.


Built with ā¤ļø using React Router, MCP, and the engine-blackjack library.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured