Dice Roller MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add dice-roller -- docker run -i --rm dice-roller-mcp-server
README.md

Provides dice rolling, coin flipping, and tabletop RPG mechanics for AI.

Dice Roller MCP Server

A Model Context Protocol (MCP) server that provides dice rolling, coin flipping, and full DnD/tabletop RPG mechanics for AI assistants.

Purpose

This MCP server gives Claude (or any MCP-compatible AI) the ability to roll dice, flip coins, and run tabletop RPG mechanics in real-time with true randomness.

Features

  • flip_coin - Flip one or more coins, get Heads/Tails results
  • roll_dice - Roll using standard NdM+K notation (e.g. 2d6, 1d20+5, 4d8-2)
  • roll_advantage - Roll with advantage (2x, take higher) for DnD 5e
  • roll_disadvantage - Roll with disadvantage (2x, take lower) for DnD 5e
  • roll_stats - Generate a full DnD character stat block (4d6 drop lowest x6)
  • roll_initiative - Roll initiative (1d20 + modifier) for DnD combat
  • roll_custom - Roll any count/sides/modifier combo with an optional label
  • roll_percentile - Roll a percentile die (d100)
  • roll_drop_lowest - Roll NdM and drop the lowest result

Prerequisites

  • Docker Desktop with MCP Toolkit enabled
  • Docker MCP CLI plugin (docker mcp command)

Installation

See INSTALLATION section at the bottom of this file, or follow the numbered steps provided when you received these files.

Usage Examples

In Claude Desktop, you can ask:

  • "Roll a d20 with +5 modifier"
  • "Flip 3 coins"
  • "Roll 2d6+3 for damage"
  • "Roll my DnD character stats"
  • "Roll initiative with +2 dex"
  • "Roll with advantage on a d20"
  • "Roll 4d6 drop lowest for strength"
  • "Roll a percentile die"
  • "Roll 3d8 for my fireball damage, label it Fireball"

Architecture

Claude Desktop -> MCP Gateway -> Dice Roller MCP Server (Docker)

No external API or secrets needed. Pure Python random module.

Development

Local Testing

# Run directly (no Docker needed for testing)
python dice_roller_server.py

# Test MCP protocol
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python dice_roller_server.py

Adding New Tools

  1. Add an async function to dice_roller_server.py
  2. Decorate with @mcp.tool()
  3. Single-line docstring only
  4. All params default to empty string ""
  5. Return a formatted string
  6. Add tool name to custom.yaml catalog
  7. Rebuild Docker image: docker build -t dice-roller-mcp-server .

Troubleshooting

  • Tools not appearing? Verify Docker image built, check catalog/registry files, restart Claude Desktop.
  • Gateway panic? Ensure all docstrings are single-line only.
  • Wrong results? All randomness uses Python's secrets-seeded random — it's fair!

Security

  • No API keys required
  • Running as non-root user in Docker
  • No network access needed

License

MIT License

Tools (9)

flip_coinFlip one or more coins, get Heads/Tails results
roll_diceRoll using standard NdM+K notation
roll_advantageRoll with advantage (2x, take higher) for DnD 5e
roll_disadvantageRoll with disadvantage (2x, take lower) for DnD 5e
roll_statsGenerate a full DnD character stat block
roll_initiativeRoll initiative (1d20 + modifier) for DnD combat
roll_customRoll any count/sides/modifier combo with an optional label
roll_percentileRoll a percentile die (d100)
roll_drop_lowestRoll NdM and drop the lowest result

Configuration

claude_desktop_config.json
{"mcpServers": {"dice-roller": {"command": "docker", "args": ["run", "-i", "--rm", "dice-roller-mcp-server"]}}}

Try it

Roll a d20 with +5 modifier
Roll 4d6 drop lowest for strength
Roll initiative with +2 dex
Roll 3d8 for my fireball damage, label it Fireball
Roll my DnD character stats

Frequently Asked Questions

What are the key features of Dice Roller?

Standard NdM+K dice notation support. DnD 5e mechanics including advantage and disadvantage. Automated character stat block generation. Initiative tracking for combat encounters. Customizable dice rolls with labels.

What can I use Dice Roller for?

Automating dice rolls during AI-led tabletop RPG sessions. Quickly generating character ability scores for new DnD campaigns. Managing combat initiative order for game masters. Resolving complex damage calculations with modifiers.

How do I install Dice Roller?

Install Dice Roller by running: docker build -t dice-roller-mcp-server .

What MCP clients work with Dice Roller?

Dice Roller works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Dice Roller docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare