mcp-dice-roller
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-dice-rollerroll a d20 for initiative"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Dice Roller Server
A Model Context Protocol (MCP) server for rolling dice using standard RPG dice notation. This server provides a tool that can roll various-sized dice and return detailed results.
Features
Standard RPG dice support (d4, d6, d8, d10, d12, d20, d100, and more)
Roll multiple dice at once (e.g., 3d6)
Dice notation parsing (e.g., "2d10", "d20")
Comprehensive input validation
Detailed results including individual rolls and totals
100% test coverage with Jest
Related MCP server: Dice Roller MCP Server
Installation
npm install
npm run buildRunning Tests
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverageTest Suite Coverage
The project includes a comprehensive test suite with 75 tests covering:
Core Dice Rolling Functionality
Dice notation parsing (e.g., "3d6", "d20")
Single and multiple dice rolls
Various dice sizes (d4, d6, d8, d10, d12, d20, d100)
Random number generation
Result formatting
Input Validation
Valid dice notation formats
Invalid notation detection
Parameter bounds checking
Edge case handling (zero, negative values, very large numbers)
Maximum limits (1000 dice max, 1,000,000 sides max)
MCP Tool Integration
Tool schema validation
Request/response formatting
Error handling and messaging
Standard RPG dice workflows
Statistical distribution verification
Test Results
Test Suites: 2 passed, 2 total
Tests: 75 passed, 75 total
Coverage: 100% statements, 100% branches, 100% functions, 100% linesUsage
As an MCP Server
The server communicates via stdio and can be integrated with MCP-compatible clients.
node dist/index.jsClaude Code Configuration
To use this MCP server with Claude Code, add the following configuration to your Claude Code settings file (.claude/claude_code_config.json or global settings):
{
"mcpServers": {
"dice-roller": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "${workspaceFolder}/mcp-test-server"
}
}
}Update the cwd path to point to the root directory of this project. The dist/index.js path is relative to the cwd.
After adding the configuration:
Ensure the project is built:
npm run buildRestart Claude Code
The
roll_dicetool will be available for use
Tool: roll_dice
Roll dice using standard dice notation.
Parameters:
notation(string): Dice notation in the format "NdS" where N is the number of dice and S is the number of sidesExamples: "3d6", "d20", "2d10"
N is optional and defaults to 1 if omitted
Examples:
d6- Roll one 6-sided died20- Roll one 20-sided die3d6- Roll three 6-sided dice2d10- Roll two 10-sided dice4d8- Roll four 8-sided dice
Response Format:
The tool returns two text items:
A human-readable formatted result
A JSON object with detailed information
Example response for "3d6":
Rolled 3d6: [4, 2, 5] = 11
{
"rolls": [4, 2, 5],
"total": 11,
"notation": "3d6",
"count": 3,
"sides": 6
}Dice Notation
The server supports standard RPG dice notation:
Notation | Description |
| Roll one 4-sided die |
| Roll one 6-sided die |
| Roll one 8-sided die |
| Roll one 10-sided die |
| Roll one 12-sided die |
| Roll one 20-sided die |
| Roll one 100-sided die (percentile) |
| Roll three 6-sided dice |
| Roll two 10-sided dice |
| Roll N dice with S sides each |
Validation Rules
Dice count must be a positive integer (1-1000)
Dice sides must be an integer ≥ 2 (up to 1,000,000)
Notation format must match the pattern
NdSordSMaximum of 1000 dice can be rolled at once
Maximum of 1,000,000 sides per die
Error Handling
The server provides clear error messages for invalid inputs:
Invalid notation format: "Invalid dice notation: {input}. Expected format: NdS (e.g., 3d6, d20)"
Invalid count: "Dice count must be a positive integer"
Invalid sides: "Dice sides must be an integer greater than or equal to 2"
Too many dice: "Cannot roll more than 1000 dice at once"
Too many sides: "Dice cannot have more than 1,000,000 sides"
Project Structure
mcp-dice-roller-server/
├── src/
│ ├── diceRoller.ts # Core dice rolling logic
│ └── index.ts # MCP server implementation
├── tests/
│ ├── diceRoller.test.ts # Core functionality tests
│ └── mcpServer.test.ts # MCP integration tests
├── dist/ # Compiled JavaScript output
├── package.json
├── tsconfig.json
├── jest.config.js
└── README.mdDevelopment
Building
npm run buildWatch Mode
npm run watchTesting
The test suite uses Jest with ts-jest for TypeScript support. Tests cover:
Dice Notation Parsing (15 tests)
Valid notation formats
Invalid notation detection
Edge cases and error handling
Parameter Validation (10 tests)
Valid parameter ranges
Boundary conditions
Type checking
Dice Rolling (25 tests)
Single and multiple dice
Range validation
Statistical distribution
Result structure
MCP Integration (25 tests)
Tool schema compliance
Request/response format
Error handling
Standard use cases
Technical Details
Language: TypeScript
Runtime: Node.js >= 18.0.0
MCP SDK: @modelcontextprotocol/sdk v1.20.0
Testing: Jest with 100% code coverage
Module System: ES Modules
Troubleshooting
Server fails to start with "exports is not defined"
If you see this error:
ReferenceError: exports is not defined in ES module scopeSolution: The TypeScript compiler must be configured to output ES modules. Ensure tsconfig.json has:
{
"compilerOptions": {
"module": "ES2020"
}
}Then rebuild:
npm run buildTests fail after configuration changes
If tests fail after modifying the TypeScript or Jest configuration:
Clean the build directory:
rm -rf distRebuild the project:
npm run buildRun tests again:
npm test
Server not appearing in Claude Desktop
Verify the path in
claude_desktop_config.jsonis absoluteCheck that the project has been built
Restart Claude Desktop
Check the Claude Desktop logs for errors
Module resolution errors
If you see import errors, ensure:
All dependencies are installed:
npm installThe project is built:
npm run buildpackage.jsonhas"type": "module"tsconfig.jsonhas"module": "ES2020"
License
MIT
Available Tools
1 toolroll_diceA
Roll dice using standard dice notation (e.g., "3d6", "d20", "2d10"). Supports rolling multiple dice of various sizes.
| Name | Required | Description | Default |
|---|---|---|---|
| notation | Yes | Dice notation in the format NdS where N is the number of dice and S is the number of sides (e.g., "3d6" for three six-sided dice, "d20" for one twenty-sided die) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, description carries full burden. Basic behavior described but lacks details on randomness, error handling, or side effects. Adequate for a simple tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two concise sentences with no waste, front-loaded with key information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given simple single-parameter tool with no output schema, description covers notation and purpose. Could mention result format but not critical.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with full parameter description. Description adds no extra meaning beyond schema, so baseline score applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Explicitly states verb 'Roll' and resource 'dice' using standard dice notation, with clear examples. No sibling tools, so differentiation is not needed.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Clear instructions to use standard dice notation and support for multiple dice. No alternatives or when-not-to-use guidance, but not required due to tool simplicity.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.0.0- First observed
roll_dice
TDQS
Scored across 1 tool
Only one tool exists, so there is no risk of confusing it with other tools.
With a single tool, naming is trivially consistent; the snake_case pattern is clear.
One tool for a focused dice-rolling purpose is appropriate, though a few auxiliary tools (e.g., for parsing or validation) could be added.
The tool fully covers the core functionality of rolling dice using standard notation, with no obvious gaps.
Maintenance
Related MCP Connectors
D&D 5e MCP — wraps the D&D 5th Edition API (free, no auth)
Transform your data analysis with our Data Compute & Stats Bot. Effortlessly calculate descriptive
Provide detailed Pokémon data and information through a standardized MCP interface. Enable LLMs an…
Renders interactive Chart.js charts and dashboards inline in AI conversations. Supports bar, line, area, pie, doughnut, scatter, and radar charts with multi-chart dashboard grids.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceProvides cryptographically secure random dice rolls for AI assistants, supporting standard and advanced dice notation for tabletop RPGs and games.8-
- FlicenseNot gradedqualityDmaintenanceEnables dice rolling mechanics for tabletop RPGs including standard dice notation, coin flips, advantage/disadvantage rolls, exploding dice, and maintains a history of recent rolls. Supports D\&D 5e mechanics and various gaming dice types (d4, d6, d8, d10, d12, d20, d100).-
- FlicenseNot gradedqualityDmaintenanceProvides comprehensive dice rolling functionality for tabletop games and RPGs, supporting standard dice notation, D\&D ability score generation, advantage/disadvantage rolls, and skill checks against difficulty classes.-
- AlicenseAqualityDmaintenanceProvides comprehensive TRPG dice rolling functionality including standard notation, advantage/disadvantage mechanics, and success-counting dice pools. It enables users to perform complex dice logic and track roll history through an MCP-compliant interface.2MIT