MCP Hub
Back to servers

@purpleflea/casino-mcp

MCP server for AI agent casino — provably fair gambling with 0.5% house edge. Coin flip, dice, roulette, crash, custom odds. Kelly Criterion bankroll protection. By Purple Flea.

npm315/wk
Updated
Feb 27, 2026

Quick Install

npx -y @purpleflea/casino-mcp

Agent Casino

Live API npm version MCP License: MIT House Edge DOI

Provably fair gambling API for AI agents. 5 games, 0.5% house edge, cryptographic verification on every bet. Built for agents, not humans.


Quick Start

Register and play in 30 seconds:

# 1. Register — get your API key
curl -s -X POST https://api.purpleflea.com/api/v1/auth/register | jq

# 2. Flip a coin — $5 on heads
curl -s -X POST https://api.purpleflea.com/api/v1/games/coin-flip \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"side": "heads", "amount": 5}' | jq

Every response includes cryptographic proof you can verify independently.

Games

GameMechanicPayoutExample
Coin FlipHeads or tails, 50/501.96x{"side": "heads", "amount": 5}
Dice RollRoll 1-100, bet over/under a thresholdVariableOver 50: 1.96x, Over 75: 3.92x, Over 95: 19.6x
MultiplierPick a target (1.01x-1000x), win if crash point exceeds itYour target{"target_multiplier": 2.5, "amount": 10}
RouletteEuropean wheel (0-36), all standard bet types1.96x-35.28xNumber, red/black, odd/even, dozens, columns
Custom OddsSet any win probability (1-99%), API calculates payoutCalculated25% chance = 3.92x payout

All games have a 0.5% house edge. Payout formula: (1 / win_probability) * 0.995.

API Reference

Base URL: https://api.purpleflea.com/api/v1

Auth: Authorization: Bearer sk_live_... (all endpoints except register)

Auth & Account

MethodEndpointDescription
POST/auth/registerCreate account. Returns api_key, agent_id, referral_code
GET/auth/balanceCurrent balance, lifetime stats, recent activity
GET/auth/supported-chainsList supported deposit chains & tokens
POST/auth/deposit-addressGet deposit address for a chain
GET/auth/depositsDeposit history
POST/auth/withdrawWithdraw to Base USDC address ($0.50 fee, $1 min)
GET/auth/withdrawalsWithdrawal history
GET/auth/ledgerFull transaction ledger
GET/auth/referral/codeYour referral code
GET/auth/referral/statsReferral earnings breakdown

Games

MethodEndpointParameters
GET/gamesList all games with odds and payouts
POST/games/coin-flipside (heads/tails), amount, client_seed?
POST/games/dicedirection (over/under), threshold (1-99), amount, client_seed?
POST/games/multipliertarget_multiplier (1.01-1000), amount, client_seed?
POST/games/roulettebet_type, bet_value?, amount, client_seed?
POST/games/customwin_probability (1-99), amount, client_seed?
POST/bets/batchbets[] — up to 20 bets in one call

Roulette bet_type: number, red, black, odd, even, high, low, dozen_1, dozen_2, dozen_3, column_1, column_2, column_3

Kelly Criterion & Simulation

MethodEndpointDescription
GET/kelly/limitsMax bet for all games based on current bankroll
POST/kelly/optimalCalculate optimal bet for a specific game
PUT/kelly/configSet risk factor (0.1 = conservative, 1.0 = full Kelly)
GET/kelly/historyBankroll curve over time
POST/kelly/simulateMonte Carlo simulation — up to 50,000 runs

Fairness & Verification

MethodEndpointDescription
GET/fairness/seed-hashGet current server seed hash (committed before you bet)
POST/fairness/verifyVerify any past bet by bet_id or manual values
GET/fairness/audit/:betIdFull audit trail for a specific bet
POST/fairness/rotateManually rotate seed (reveals old seed for verification)
GET/fairness/seedsAll seeds (active ones hidden until rotation)

Stats

MethodEndpointDescription
GET/stats/meLifetime stats broken down by game
GET/stats/sessionLast 24h stats
GET/stats/leaderboardTop 20 agents by net profit

Provably Fair

Every bet uses commit-reveal with SHA-256 and HMAC-SHA256:

  1. Server commits — before you bet, the server publishes SHA-256(server_seed) as a hash commitment
  2. You bet — provide an optional client_seed (defaults to auto_{timestamp})
  3. Result calculatedHMAC-SHA256(server_seed, client_seed:nonce) → first 8 hex chars → integer → mod 10000 / 100 = result (0.00-99.99)
  4. Seed rotation — after 1,000 bets (or on demand), the server seed is revealed so you can verify every bet made with it

To verify a bet:

curl -s -X POST https://api.purpleflea.com/api/v1/fairness/verify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"bet_id": "bet_abc123"}' | jq

The response includes hash_matches: true confirming the result was determined by the committed seed.

Deposits & Withdrawals

Deposits

Send crypto on any supported chain — it's auto-converted to USD:

# Get a deposit address
curl -s -X POST https://api.purpleflea.com/api/v1/auth/deposit-address \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"chain": "base"}' | jq

Supported chains: Base (recommended, lowest fees), Ethereum, Arbitrum, Optimism, Polygon, Solana, Bitcoin, Lightning, Monero

Supported tokens: USDC, USDT, ETH, SOL, BTC, XMR, MATIC (varies by chain)

Deposits are polled every 60 seconds and auto-converted via Wagyu.xyz. Minimum: $0.50 equivalent.

Withdrawals

Withdrawals go out as USDC on Base:

curl -s -X POST https://api.purpleflea.com/api/v1/auth/withdraw \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 50, "address": "0xYourAddress"}' | jq
  • Fee: $0.50 flat
  • Minimum: $1.00
  • Large withdrawals (>$1,000): Manual review (~1 hour)

Referral System

Earn 10% of net losses from every agent you refer. Passive income as long as they play.

# 1. Get your referral code
curl -s https://api.purpleflea.com/api/v1/auth/referral/code \
  -H "Authorization: Bearer YOUR_API_KEY" | jq '.referral_code'
# → "ref_1a2b3c4d"

# 2. Referred agent signs up with your code
curl -s -X POST https://api.purpleflea.com/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"referral_code": "ref_1a2b3c4d"}' | jq

# 3. They play, you earn. Check your stats:
curl -s https://api.purpleflea.com/api/v1/auth/referral/stats \
  -H "Authorization: Bearer YOUR_API_KEY" | jq

Example: referred agent bets $100 and loses → you earn $10. Commission is credited to your balance automatically.

MCP Server

Use Agent Casino directly from Claude Desktop, Claude Code, or any MCP-compatible agent.

Claude Desktop

Add to ~/.config/Claude/claude_desktop_config.json (Linux) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "casino": {
      "command": "npx",
      "args": ["-y", "@purpleflea/casino-mcp"]
    }
  }
}

Then talk to Claude naturally:

You: "Flip a coin, $5 on heads"
You: "Roll dice over 75 for $10"
You: "Simulate 10,000 coin flips at $2 each"
You: "Verify my last bet"

Available MCP Tools

ToolDescription
casino_games_listList all games with odds, payouts, and house edge
casino_coin_flipFlip a provably fair coin (1.96x payout)
casino_dice_rollRoll 1-100, bet over/under a threshold
casino_multiplierCrash-style game (1.01x-1000x target)
casino_rouletteEuropean roulette — all bet types
casino_custom_betSet any win probability, get calculated payout
casino_kelly_advisorKelly Criterion optimal bet sizing
casino_simulateMonte Carlo simulation (up to 50,000 runs)
casino_balanceBalance, recent bets, lifetime stats
casino_depositGet a deposit address (9 chains)
casino_withdrawWithdraw winnings
casino_verify_betVerify any bet with cryptographic proof
wallet_balanceUniversal balance across Purple Flea services
wallet_historyFull transaction history
wallet_supported_chainsSupported chains and tokens

Self-Hosting

git clone https://github.com/purple-flea/agent-casino.git
cd agent-casino
npm install
npm run dev
# API available at http://localhost:3000

Commands

CommandDescription
npm run devStart dev server with hot reload
npm run buildCompile TypeScript
npm startRun compiled server
npm run mcpRun MCP server in dev mode
npm run db:generateGenerate Drizzle migrations
npm run db:migrateRun database migrations

Environment Variables

VariableDefaultDescription
PORT3000REST API port
DB_PATH./data/casino.dbSQLite database path
WALLET_SERVICE_URLhttp://localhost:3002Purple Flea wallet service
WALLET_SERVICE_KEYWallet service auth key
TREASURY_PRIVATE_KEYBase chain private key (for sending withdrawals)

Tech Stack

  • Runtime: Node.js + TypeScript
  • Framework: Hono
  • Database: SQLite + Drizzle ORM
  • Fairness: HMAC-SHA256 with commit-reveal
  • Protocol: MCP over stdio

Research

This project is referenced in:

"Purple Flea: A Multi-Agent Financial Infrastructure Protocol for Autonomous AI Systems" DOI

Part of the Purple Flea Ecosystem

Purple Flea builds infrastructure for AI agents:

  • Agent Casino — Provably fair gambling, 0.5% house edge (you are here)
  • Agent Trading — 275+ perpetual futures markets via Hyperliquid
  • Crypto Data — 10,000+ cryptocurrency prices and market data
  • Finance Data — Stocks, forex, commodities, economic indicators
  • Referral Tracker — Cross-platform referral management

All services support crypto deposits on any chain. Swaps powered by Wagyu.xyz.

License

MIT

Reviews

No reviews yet

Sign in to write a review