Skip to content
RANDSUMplugin

RANDSUM plugin

Real dice for Claude and other agents

Everything an AI agent needs to roll for real: skills for notation, odds and game specs, and the RANDSUM MCP server, as a Claude Code plugin or a Claude connector.

Terminal window
/plugin marketplace add RANDSUM/randsum
/plugin install randsum@randsum

RANDSUM provides a Claude Code plugin with skills that give AI agents specialized knowledge for tabletop RPG dice mechanics, and a /roll command for rolling your own dice. It is one of the ways to give an AI agent RANDSUM. In claude.ai, Claude Desktop or mobile, add the Claude connector instead, at https://api.randsum.dev/mcp.

Dice Rolling

Turn a request in plain words (“attack with advantage, +5”) into a real roll through the RANDSUM MCP server or HTTP API, and explain the result. Never invents a number.

RANDSUM Library

Write code that rolls dice with @randsum/roller and @randsum/games: notation, validating user input, seeded tests, game mechanics, and the REST API for other languages.

Dice Probability

Analyze probability distributions, expected values, and outcome comparisons. Compare strategies like “advantage vs. flat +2” with exact math or Monte Carlo simulation.

Game Spec Creator

Create .randsum.json specs for custom TTRPG dice mechanics. Translate tabletop game rules into declarative specs that generate typed TypeScript roll() functions via codegen.

A skill is a markdown document that gives Claude specialized knowledge. When Claude loads a RANDSUM skill, it learns domain-specific concepts (dice notation syntax, probability math, or the .randsum.json spec format) and can apply them to your questions without you needing to explain the domain.

Skills activate automatically based on context. Ask naturally:

Roll 4d6 drop lowest for my strength score
What are the odds of rolling 15+ on 3d6?
Create a .randsum.json spec for Ironsworn

Or invoke explicitly with /randsum:dice-rolling, /randsum:randsum-library, /randsum:dice-probability, or /randsum:game-spec-creator (plugin skills are namespaced by the plugin name).

The plugin adds a /roll command that rolls on your machine with the RANDSUM engine, with no model turn and no tokens:

/roll 4d6L
/roll 1d20 + 5, 2d6

The result prints at once and stays on the status line, and Claude is told the number as your roll, so it reacts to it instead of rolling for you. That suits a game where Claude is the GM and you want to throw your own dice. /roll with no notation rolls a d20.

/roll is a Claude Code mod (a hooks module), an early-access feature of recent Claude Code builds. On a build without it, the command is simply absent and the rest of the plugin works as before. It is not available in claude.ai or Claude Desktop chat; there, ask Claude to roll and the connector does it.

All skill files live in the plugins/randsum/skills/ directory.

Add the RANDSUM marketplace and install the plugin from inside Claude Code:

Terminal window
/plugin marketplace add RANDSUM/randsum
/plugin install randsum@randsum

On Claude Code 2.1.275 or later, one command does both: /plugin install randsum --marketplace RANDSUM/randsum.

The plugin also connects the hosted @randsum/mcp server at https://api.randsum.dev/mcp, so the skills can roll with the real engine instead of simulating, with nothing to install. You do not need a separate claude mcp add.

Staying current. The plugin tracks the marketplace’s commits rather than a version number. Run /plugin marketplace update randsum to pick up changes, or turn on Enable auto-update for the randsum marketplace under Marketplaces in /plugin.

For a whole team. Run these once in your project’s shell and commit the .claude/settings.json they write. Everyone who trusts the folder is then offered the marketplace and the plugin:

Terminal window
claude plugin marketplace add RANDSUM/randsum --scope project
claude plugin install randsum@randsum --scope project

The core skill for an agent rolling dice in conversation. It turns a natural-language request into a call to the RANDSUM MCP tools (roll, roll_game, validate) or the HTTP API, and reports the result for seven supported game systems: D&D 5e, Blades in the Dark, Daggerheart, Fate Core, PbtA, Root RPG, and Salvage Union.

What the agent learns:

  • Never to invent a roll, and which tool to reach for first (the MCP tools, then the HTTP API)
  • How common phrasings map to calls (“roll stats” is 4d6Lx6, “Blades with 3 dice” is roll_game with rating: 3)
  • RANDSUM notation (4d6L, 2d20H+5, 3d6!, d%, 4dF, etc.) and each game’s inputs and outcomes
  • How to report dice, total and meaning in one compact block

Files:

For an agent writing code. Teaches which package fits (@randsum/roller, a @randsum/games subpath, or the REST API from another language) and how to use it well.

What the agent learns:

  • roll() arguments and the result shape (total, values, per-group rolls with initialRolls)
  • Validating user-typed notation with validateNotation and suggestNotationFix, and catching RandsumError
  • Each game’s typed roll() input and result union
  • Seeded rolls for tests, narrow subpath imports for small bundles, and when to use the REST API

Files:

Teaches an agent to analyze probability distributions for dice rolls. Handles exact enumeration for small outcome spaces and Monte Carlo simulation for complex rolls.

What the agent learns:

  • Expected values, variance, and standard deviation for any notation
  • Probability of hitting specific thresholds (e.g., “odds of 15+ on 3d6”)
  • Comparative analysis (“advantage vs. flat +2 bonus”)
  • Game-system outcome probabilities (e.g., “chance of critical success in Blades”)

Files:

Teaches an agent the .randsum.json spec format: a declarative JSON Schema for describing tabletop RPG dice mechanics. Specs define a four-stage pipeline (Dice → Modify → Resolve → Outcome) and generate typed TypeScript roll() functions via codegen.

What the agent learns:

  • The full .randsum.json schema (pools, modifiers, conditions, outcome tables)
  • How to translate natural-language game rules into declarative specs
  • Reference resolution ($ref for reusable components)
  • Validation rules and common patterns across game systems

Files:

If you’re building a custom agent, you can also use @randsum/roller directly:

Terminal window
bun add @randsum/roller
import { roll } from '@randsum/roller'
const result = roll('4d6L')
console.log(result.total) // Sum after dropping lowest
console.log(result.values) // Kept die values, e.g. [6, 4, 3]

See the Roller documentation for the full API.

The full skill file that agents receive:

Dice Rolling

Turn what the user asked for into a RANDSUM roll, get the result from the real engine, and report it. Never invent a dice result. Language models are not random; a made-up roll is a wrong answer even when it looks plausible.

1. Pick the tool

Use the first one available:

  1. RANDSUM MCP tools. This plugin connects them (claude.ai users add https://api.randsum.dev/mcp as a connector). In Claude Code they are listed as mcp__plugin_randsum_randsum__roll and so on.
    • roll_game when the user names a supported game. It returns the game’s outcome, not just a number.
    • roll for plain notation.
    • validate to check or explain notation, or to repair notation roll rejected.
  2. The HTTP API at https://api.randsum.dev/v1, if you have a web fetch tool or an HTTP client. Public, keyless, JSON:
    • GET /v1/roll?notation=4d6L (URL-encode: + is %2B, { is %7B, } is %7D)
    • GET /v1/games/<game>/roll?<inputs>, e.g. /v1/games/blades/roll?rating=3
    • GET /v1/validate?notation=..., GET /v1/random?min=1&max=100&count=5, GET /v1/games
    • POST with a JSON body works for roll, validate and game rolls too, and avoids URL encoding.
  3. Neither available: tell the user you cannot roll real dice here and give the notation they can roll themselves. Only simulate if they ask you to, and label it simulated.

2. Translate the request

The user says Call
“Roll a d20” / “roll 2d6+3” roll with 1d20 / 2d6+3
“Attack with advantage, +5” (D&D) roll_game fifth { "modifier": 5, "rollingWith": "Advantage", "crit": true }
“Roll stats” / “ability scores” roll with 4d6Lx6
“Roll 3 dice for Blades” / “action rating 2 plus a push” roll_game blades { "rating": 3 }
“Duality roll, +2, with advantage” (Daggerheart) roll_game daggerheart { "modifier": 2, "rollingWith": "Advantage" }
“Fate roll, Good skill” roll_game fate { "modifier": 3 }
“Roll +Hard” with Hard 2 (PbtA) roll_game pbta { "stat": 2 }
“Roll on the Morale table” (Salvage Union) roll_game salvageunion { "tableName": "Morale" }
“Fireball damage” roll with 8d6
“Crit with my longsword, +3” roll with 2d8+3 (double the dice, not the modifier)
“Five d10s, count 8 or higher” roll with 5d10S{8}
“Roll percentile” roll with d%

Rules of thumb:

  • Ask only when a required number is missing and you cannot reasonably assume it (a PbtA stat, a Salvage Union table). Otherwise assume the common default and say so (“assuming no modifier”).
  • One call per independent roll. Attack and damage are two calls, because damage only happens on a hit. Use xN (4d6Lx6) for N identical rolls.
  • Pass a seed only when the user asks for a reproducible or shareable roll.
  • On an error, read the message and the suggestion, fix the notation once (or call validate), and retry. Do not loop.
  • Unsupported games roll as plain notation; interpret by the game’s rules yourself.

Each game’s inputs, ranges and outcomes: references/GAME_SYSTEMS.md.

3. Report the result

Show, in one compact block:

  1. What was rolled: the notation or game roll, and what it is for
  2. The dice: values from the tool, marking dropped or rerolled dice when it tells you
  3. The total
  4. What it means in the game: hit or miss, success tier, Hope or Fear, ladder rung, table entry
Strength (4d6L): rolled [5, 3, 4, 2], dropped the 2 → 12 (modifier +1)
Blades, 3 dice: [2, 5, 4] → highest 5: partial success.
You do it, but there's a consequence: harm, a complication, or reduced effect.

Report the numbers exactly as returned. Add at most one sentence of flavour for game rolls. Don’t explain notation unless asked.

Notation quick reference

Case-insensitive. NdS rolls N dice with S sides; d20 means 1d20.

Notation Meaning
1d20+5 Add 5 (- subtracts)
4d6L Drop the lowest (L2 drops two)
2d20H Drop the highest
4d6K3 Keep the highest 3
4d6kl2 Keep the lowest 2
4d6R{1} Reroll 1s
4d20R{<5} Reroll under 5
3d6! Explode: roll again on a max
3d6!! Compound: add the extra roll to the same die
3d6!p Penetrate: explode, minus 1 each time
4d20C{>18} Cap results over 18 at 18
4d20V{1=20} Replace 1s with 20s
4d20U Every die unique
5d10S{7} Count dice at 7 or over as successes
5d10S{7,1} Successes at 7+, minus botches at 1
5d10F{3} Count dice at 3 or under as failures
5d6W D6 System wild die
2d6*2 Multiply the dice sum, before +/-
2d6+3**2 Multiply the final total
4d6//2 Integer-divide the total
4d6%3 Total modulo 3
4dF Fate dice
d% Percentile, 1d100
g6 Geometric die: roll d6 again while it shows 6, sum every roll
3DD6 Draw 3 from a d6 without replacement
4d6Lx6 Repeat 6 times
2d6+3[fire] Label a group
1d20+2d6+5 Several groups, one total

Conditions: >N, <N, >=N, <=N, =N or a bare N (exact). Modifiers run in a fixed order whatever order they are written in; references/NOTATION.md has the order and every modifier in full, and https://notation.randsum.dev/ is the specification.

RANDSUM Dice Notation

Table of Contents


Overview

Dice notation is a compact way to represent dice rolls and their modifications. For example, 4d20+2 means “roll four twenty-sided dice, then add two”.

RANDSUM extends standard dice notation with modifiers like dropping the lowest rolls, rerolling specific values, and ensuring unique results. This reference covers the common features; the Notation Syntax Guide and the specification cover the rest, including Fate, percentile, zero-bias and custom-faced dice, reroll once (ro{..}), explode sequences (!s{..}, !i, !r), keep middle (KM), margin of success (ms{..}) and sort (sa, sd).

The core roll() function accepts several argument types: a number (sides for a single die, e.g. roll(20) for 1d20), a notation string (e.g. roll("4d6L")), an options object (e.g. roll({ sides: 6, quantity: 4, modifiers: { drop: { lowest: 1 } } })), or multiple arguments combined into one total (e.g. roll("1d20+5", "2d6")).

Basic Syntax

All RANDSUM notation is case-insensitive (2d8 = 2D8).

Standard Rolls
// Roll one d20
roll(20) // number argument
roll("1d20") // notation string
roll({
sides: 20,
quantity: 1
})
// Roll four d6
roll("4d6")
roll({
sides: 6,
quantity: 4
})

Special Dice

Geometric Die (gN)

Roll dN again while it shows N; the result is the sum of every roll. Safety cap at 1000 iterations.

roll("g6") // e.g. [6, 6, 2] → 14 (mean 4.2)
roll("3g6") // Three independent geometric rolls
Draw Die (DDN)

Sampling without replacement — like drawing from a deck. Uses Fisher-Yates shuffle.

roll("DD6") // Draw one unique value from [1..6]
roll("3DD6") // Draw 3 unique values
roll("6DD6") // Full permutation of [1,2,3,4,5,6]
roll("8DD6") // Full permutation + 2 more (reshuffles after exhaustion)

Modifiers

Basic Arithmetic
roll("4d6+2") // Add 2 to total
roll({
sides: 6,
quantity: 4,
modifiers: { plus: 2 }
})
roll("4d6-1") // Subtract 1 from total
roll({
sides: 6,
quantity: 4,
modifiers: { minus: 1 }
})
Cap Modifiers

Limit roll values to specific ranges:

roll("4d20C{>18}") // Cap rolls over 18 to 18
roll({
sides: 20,
quantity: 4,
modifiers: {
cap: { greaterThan: 18 }
}
})
roll("4d20C{<3}") // Cap rolls under 3 to 3
roll({
sides: 20,
quantity: 4,
modifiers: {
cap: { lessThan: 3 }
}
})
roll("4d20C{<2,>19}") // Cap rolls under 2 to 2 and over 19 to 19
roll({
sides: 20,
quantity: 4,
modifiers: {
cap: {
greaterThan: 19,
lessThan: 2
}
}
})
Drop Modifiers

Drop specific dice from the results:

roll("4d6L") // Drop lowest
roll({
sides: 6,
quantity: 4,
modifiers: { drop: { lowest: 1 } }
})
roll("4d6L2") // Drop 2 lowest
roll({
sides: 6,
quantity: 4,
modifiers: { drop: { lowest: 2 } }
})
roll("4d6H") // Drop highest
roll({
sides: 6,
quantity: 4,
modifiers: { drop: { highest: 1 } }
})
roll("4d6H2") // Drop 2 highest
roll({
sides: 6,
quantity: 4,
modifiers: { drop: { highest: 2 } }
})
roll("4d6LH") // Drop both lowest and highest
roll({
sides: 6,
quantity: 4,
modifiers: { drop: { lowest: 1, highest: 1 } }
})
// Drop by value
roll("4d20D{>17}") // Drop rolls over 17
roll({
sides: 20,
quantity: 4,
modifiers: { drop: { greaterThan: 17 } }
})
roll("4d20D{<5}") // Drop rolls under 5
roll({
sides: 20,
quantity: 4,
modifiers: { drop: { lessThan: 5 } }
})
roll("4d20D{8,12}") // Drop 8s and 12s
roll({
sides: 20,
quantity: 4,
modifiers: { drop: { exact: [8, 12] } }
})
Reroll Modifiers

Reroll dice matching certain conditions:

roll("4d20R{>17}") // Reroll results over 17
roll({
sides: 20,
quantity: 4,
modifiers: { reroll: { greaterThan: 17 } }
})
roll("4d20R{<5}") // Reroll results under 5
roll({
sides: 20,
quantity: 4,
modifiers: { reroll: { lessThan: 5 } }
})
roll("4d20R{8,12}") // Reroll 8s and 12s
roll({
sides: 20,
quantity: 4,
modifiers: { reroll: { exact: [8, 12] } }
})
roll("4d20R{<5}3") // Reroll under 5, rerolling at most 3 dice
roll({
sides: 20,
quantity: 4,
modifiers: {
reroll: {
lessThan: 5,
max: 3
}
}
})
Replace Modifiers

Replace specific results with new values:

roll("4d20V{8=12}") // Replace 8s with 12s
roll({
sides: 20,
quantity: 4,
modifiers: {
replace: {
from: 8,
to: 12
}
}
})
roll("4d20V{>17=20}") // Replace results over 17 with 20
roll({
sides: 20,
quantity: 4,
modifiers: {
replace: {
from: { greaterThan: 17 },
to: 20
}
}
})
roll("4d20V{<5=1}") // Replace results under 5 with 1
roll({
sides: 20,
quantity: 4,
modifiers: {
replace: {
from: { lessThan: 5 },
to: 1
}
}
})
Unique Results

Force unique rolls within a pool:

roll("4d20U") // All results must be unique
roll({
sides: 20,
quantity: 4,
modifiers: { unique: true }
})
roll("4d20U{5,10}") // Unique except 5s and 10s can repeat
roll({
sides: 20,
quantity: 4,
modifiers: {
unique: { notUnique: [5, 10] }
}
})
Keep Modifiers

Keep specific dice from the result (complement to drop):

roll("4d6K3") // Keep highest 3
roll({
sides: 6,
quantity: 4,
modifiers: { keep: { highest: 3 } }
})
roll("4d6K") // Keep highest 1
roll({
sides: 6,
quantity: 4,
modifiers: { keep: { highest: 1 } }
})
roll("4d6kl2") // Keep lowest 2
roll({
sides: 6,
quantity: 4,
modifiers: { keep: { lowest: 2 } }
})
roll("4d6kl") // Keep lowest 1
roll({
sides: 6,
quantity: 4,
modifiers: { keep: { lowest: 1 } }
})

Note: Keeping N highest is equivalent to dropping (quantity - N) lowest. For example, 4d6K3 is the same as 4d6L1.

Exploding Dice

Roll additional dice on maximum results:

roll("4d20!") // Roll an extra d20 for each 20 rolled
roll({
sides: 20,
quantity: 4,
modifiers: { explode: true }
})

Plain explode takes no depth: 3d6!5 and 3d6!0 are rejected. Use compound (!!N) or penetrate (!pN) when you need a depth.

How it works: When a die shows its maximum value, it “explodes” - a new die is rolled and added to the result. This continues for each new maximum value rolled, creating additional dice in the result.

Example: 3d6! rolls [6, 4, 6]. The two 6s explode, adding [5, 3]. Final result: [6, 4, 6, 5, 3] = 24.

Compounding Exploding (!!)

Exploding dice that add to the triggering die instead of creating new dice:

roll("3d6!!") // Compound explode: add to die instead of new dice
roll({
sides: 6,
quantity: 3,
modifiers: { compound: true }
})
roll("3d6!!5") // Compound explode with max depth of 5
roll({
sides: 6,
quantity: 3,
modifiers: { compound: 5 }
})
roll("3d6!!0") // Compound explode unlimited (capped at 1000)
roll({
sides: 6,
quantity: 3,
modifiers: { compound: 0 }
})

How it works: When a die shows its maximum value, it compounds - a new roll is added directly to that die’s value. Unlike regular exploding, this doesn’t create new dice; it modifies the existing die.

Example: 1d6!! rolls 6. This compounds, rolling 4. The die value becomes 6 + 4 = 10. If that 4 had been a 6, it would compound again: 6 + 6 + 3 = 15.

Use cases: Compounding is useful in systems where you want explosive growth on a single die value rather than multiple dice. Common in damage systems where a critical hit adds to the base damage value.

Differences from Explode:

  • Explode (!): Creates new dice → [6, 4, 6] becomes [6, 4, 6, 5, 3] (5 dice)
  • Compound (!!): Modifies existing die → [6, 4, 6] becomes [15, 4, 12] (still 3 dice)
Penetrating Exploding (!p)

Exploding dice where each subsequent explosion subtracts 1 (Hackmaster-style):

roll("3d6!p") // Penetrate explode: subtract 1 from subsequent rolls
roll({
sides: 6,
quantity: 3,
modifiers: { penetrate: true }
})
roll("3d6!p5") // Penetrate with max depth of 5
roll({
sides: 6,
quantity: 3,
modifiers: { penetrate: 5 }
})
roll("3d6!p0") // Penetrate unlimited (capped at 1000)
roll({
sides: 6,
quantity: 3,
modifiers: { penetrate: 0 }
})

How it works: When a die shows its maximum value, it penetrates - a new roll is made, but 1 is subtracted from the result before adding. Each subsequent penetration also subtracts 1. This creates a diminishing return effect.

Example: 1d6!p rolls 6. This penetrates, rolling 5. The value added is 5 - 1 = 4, so the die becomes 6 + 4 = 10. If that roll had been a 6, it would penetrate again: roll 3, subtract 1 = 2, so the die becomes 6 + 4 + 2 = 12.

Use cases: Penetrating dice are used in Hackmaster and similar systems where you want explosive results but with diminishing returns to prevent unlimited growth.

Comparison:

  • Explode (!): [6] → [6, 6, 4] = 16 (new dice added)
  • Compound (!!): [6] → [16] = 16 (die value modified)
  • Penetrate (!p): [6] → [12] = 12 (6 + (6-1) + (3-1) if it keeps penetrating, die value modified with -1 on each subsequent roll)
Pre-Arithmetic Multiplier (*)

Multiply the dice sum before adding/subtracting arithmetic modifiers:

roll("2d6*2+3") // (dice sum * 2) + 3
roll({
sides: 6,
quantity: 2,
modifiers: {
multiply: 2,
plus: 3
}
})
roll("4d6*3") // Multiply dice sum by 3
roll({
sides: 6,
quantity: 4,
modifiers: { multiply: 3 }
})

How it works: The multiplier is applied to the sum of all dice after other modifiers (drop, keep, explode, etc.) but before plus/minus arithmetic modifiers are applied.

Order of operations: (dice sum × multiply) ± plus/minus

Example: 2d6*2+3 rolls [4, 5] = 9. Multiplied by 2 = 18. Plus 3 = 21.

Use cases: Critical hits that double or triple base damage before modifiers. Or systems where dice are multiplied before bonuses are added.

Total Multiplier (**)

Multiply the entire final total after all other modifiers:

roll("2d6+3**2") // (dice + 3) * 2
roll({
sides: 6,
quantity: 2,
modifiers: {
plus: 3,
multiplyTotal: 2
}
})
roll("4d6L+2**3") // ((drop lowest) + 2) * 3
roll({
sides: 6,
quantity: 4,
modifiers: {
drop: { lowest: 1 },
plus: 2,
multiplyTotal: 3
}
})

How it works: The total multiplier is applied last, after all other modifiers including plus/minus. It multiplies the complete final result.

Order of operations: ((dice sum × multiply) ± plus/minus) × multiplyTotal

Example: 2d6+3**2 rolls [4, 5] = 9. Plus 3 = 12. Multiplied by 2 = 24.

Use cases: Final multipliers like area effect multipliers, critical hit total multipliers, or system-wide bonuses that apply to the entire result.

Difference from Pre-Arithmetic Multiplier:

  • Pre-Arithmetic (*): 2d6*2+3 = (9 × 2) + 3 = 21
  • Total (**): 2d6+3\*\*2 = (9 + 3) × 2 = 24
Count Successes (S{…})

Count dice meeting a threshold instead of summing values. Used in dice pool systems like World of Darkness and Shadowrun:

roll("5d10S{7}") // Count how many dice rolled >= 7
roll({
sides: 10,
quantity: 5,
modifiers: {
count: { greaterThanOrEqual: 7 }
}
})
// With botch threshold (successes - botches)
roll("5d10S{7,1}") // Count successes >= 7, subtract botches <= 1
roll({
sides: 10,
quantity: 5,
modifiers: {
count: {
greaterThanOrEqual: 7,
lessThanOrEqual: 1,
deduct: true
}
}
})

How it works: Instead of summing dice values, the total becomes a count of dice that meet or exceed the threshold. If a botch threshold is specified, dice at or below that value are subtracted from the success count.

Example: 5d10S{7} rolls [8, 3, 10, 6, 9]. Successes >= 7: [8, 10, 9] = 3.

Example with botch: 5d10S{7,1} rolls [8, 1, 10, 1, 9]. Successes: 3, Botches: 2. Result = 1.

Integer Division (//N)

Integer divide the total (truncates toward zero via Math.trunc):

roll("4d6//2") // Integer divide total by 2
roll({
sides: 6,
quantity: 4,
modifiers: { integerDivide: 2 }
})
Modulo (%N)

Apply modulo to the total:

roll("4d6%3") // Total modulo 3
roll({
sides: 6,
quantity: 4,
modifiers: { modulo: 3 }
})
Count Failures (F{N})

Count how many dice rolled at or below a threshold. Requires curly braces to avoid conflict with Fate dice:

roll("5d10F{3}") // Count dice that rolled <= 3
roll({
sides: 10,
quantity: 5,
modifiers: {
count: { lessThanOrEqual: 3 }
}
})
Wild Die (W)

D6 System wild die (West End Games). Last die is “wild”:

  • Wild = max (6): compound explode (keep rolling and adding while max)
  • Wild = 1: remove wild die AND highest non-wild die
  • Otherwise: no change
roll("5d6W") // Last die is wild
roll({
sides: 6,
quantity: 5,
modifiers: { wildDie: true }
})
Annotations/Labels ([text])

Attach metadata labels to dice terms — flavor text with no mechanical effect:

roll("2d6+3[fire]+1d4[cold]") // Labels on roll groups
roll("4d6L[strength]") // Label the roll purpose
Repeat Operator (xN)

Repeat a roll expression N times (notation sugar):

roll("4d6Lx6") // Equivalent to six separate 4d6L rolls
roll("2d6+3x4") // Roll 2d6+3 four times
Combining Modifiers

Modifiers can be chained together. They are applied in a specific order to ensure consistent results:

Modifier Application Order (the engine’s priority, lowest first; the order you write them in does not matter):

  1. Cap (10)
  2. Replace (30)
  3. Reroll (40)
  4. Explode / Compound / Penetrate / Explode sequence (50–53)
  5. Wild Die (55)
  6. Unique (60)
  7. Drop / Keep (65 / 66)
  8. Count Successes / Count Failures (80)
  9. Pre-Arithmetic Multiply (*) (85)
  10. Plus / Minus (90 / 91)
  11. Integer Divide (93) / Modulo (94)
  12. Sort (95)
  13. Total Multiply (**) (100)
roll("4d6L+2") // Drop lowest, add 2
roll("2d20H!+1") // Explode, then drop highest, add 1
roll("4d6R{<3}L") // Reroll under 3, then drop lowest
roll("3d6!!*2+3") // Compound explode, multiply by 2, add 3
roll("2d6*2+3**2") // Multiply dice by 2, add 3, multiply total by 2
roll("4d6K3!+2") // Explode, then keep highest 3, add 2
roll("3d6!pL+1") // Penetrate explode, drop lowest, add 1
roll("5d6W+2") // Wild die with modifier
roll("4d6Lx6") // Six ability score rolls

Important Notes:

  • Pre-arithmetic multiply (*) applies before plus/minus: 2d6*2+3 = (sum × 2) + 3
  • Total multiply (**) applies after everything: 2d6+3**2 = (sum + 3) × 2
  • You can use both multipliers together: 2d6*2+3**2 = ((sum × 2) + 3) × 2
  • Reroll and explode run before drop/keep, so an exploded die can itself be dropped: 4d6!L explodes first, then drops the lowest of everything rolled
  • Cap runs first of all, so 4d6C{>4}L caps every die before the lowest is dropped

Multiple Dice Groups in a Single Roll

You can roll several dice groups in a single call by passing multiple arguments:

roll("1d20", "-2d6", "10d8+2") // Roll 1d20, subtract 2d6, add 10d8 + 2
roll("1d20-2d6+10d8+2") // Same as above, but in a single string

Adding or Subtracting Rolls from the Total

You can add or subtract rolls from the total by using the arithmetic option, or by adding a + or - to the notation:

roll("2d12-1d6") // Roll 2d12, add them, then subtract 1d6

Common Use Cases

D&D 5e Critical Hits
  • Double base damage: 2d6+3*2 → (9 × 2) + 3 = 21
  • Double total damage: 2d6+3**2 → (9 + 3) × 2 = 24
D&D 5e Ability Score Generation
roll("4d6K3") // Roll 4d6, keep highest 3
roll("4d6L") // Equivalent: Roll 4d6, drop lowest 1
D&D 5e Advantage/Disadvantage
roll("2d20K") // Advantage: keep highest
roll("2d20kl") // Disadvantage: keep lowest
Hackmaster Penetrating Dice
roll("1d6!p") // Standard penetrate
roll("2d6!p+3") // Penetrate with modifier
Area Effect Spells
roll("8d6*2") // 8d6 damage, doubled for area effect
roll("8d6+5**2") // 8d6+5 damage, doubled for area effect

Performance Considerations

Depth Limits

All explosive modifiers (explode, compound, penetrate) have built-in depth limits:

  • Explicit depth: !!N, !pN - Limited to N depth
  • Unlimited (0): !!0, !p0 - Capped at 1000 for safety
  • Default: !, !!, !p - Keep going while each new roll is a maximum, capped at 1000
Best Practices
  1. Use depth limits for explosive modifiers in production code
  2. Keep dice quantities reasonable (< 100 dice for best performance)
  3. Prefer compound over explode if you don’t need separate dice tracking
  4. Use multipliers sparingly - they’re cheap but unnecessary if not needed

Attribution

The extended notation syntax was inspired by Sophie’s Dice.

RANDSUM Game Systems

Each supported game has a shortcode. Pass it as game to the roll_game MCP tool, or put it in the HTTP path /v1/games/<shortcode>/roll. The inputs below are the tool’s params and the HTTP query (or JSON body) fields. GET https://api.randsum.dev/v1/games lists them live.

Every game roll returns total, result (the game’s outcome), rolls (only the dice that count) and, for some games, details.

Contents

D&D 5th Edition (fifth)

1d20 + modifier. Advantage rolls 2d20 and keeps the highest; disadvantage keeps the lowest.

Input Type Notes
modifier integer, -30 to 30 Default 0
rollingWith "Advantage" or "Disadvantage" Optional
crit boolean When true, details.criticals reports isNatural1 / isNatural20

result is the number (d20 + modifier). Pass crit: true for attack rolls and saving throws where a natural 1 or 20 matters.

Plain notation equivalents: 1d20+5, advantage 2d20L+5 (drop lowest), disadvantage 2d20H+5 (drop highest). Ability scores are 4d6L, or 4d6Lx6 for all six. Critical damage doubles the dice, not the modifier: 2d6+3 becomes 4d6+3.

Blades in the Dark (blades)

Roll a pool of d6s and read the highest die.

Input Type Notes
rating integer, 0 to 10 Pool size: action rating plus assists, push, and bonus dice. Default 1
Highest die result
Two or more 6s critical
6 success
4–5 partial
1–3 failure

A rating of 0 rolls 2d6 and keeps the lowest; it can never be a critical.

Daggerheart (daggerheart)

Two d12s, a Hope die and a Fear die. Their sum plus the modifier is the total; whichever die is higher decides who gains narrative control.

Input Type Notes
modifier integer, -30 to 30 Default 0
rollingWith "Advantage" or "Disadvantage" Adds or subtracts a d6
amplifyHope boolean Hope die becomes a d20
amplifyFear boolean Fear die becomes a d20

result is hope, fear, or critical_hope (the two dice tie, which is a critical success). details holds hope.roll, fear.roll, modifier and extraDie (the advantage or disadvantage d6).

Fate Core (fate)

Four Fate dice (4dF, each -1, 0 or +1) plus a skill rating, read on the Fate ladder.

Input Type Notes
modifier integer, -2 to 5 Skill rating. Default 0

result is the ladder rung: terrible (-2 or less), poor (-1), mediocre (0), average (1), fair (2), good (3), great (4), superb (5), fantastic (6), epic (7), legendary (8+).

Powered by the Apocalypse (pbta)

2d6 + stat, the generic engine behind Apocalypse World, Dungeon World, Monster of the Week, Masks and others.

Input Type Notes
stat integer, -3 to 5 Required
forward integer, -5 to 5 One-time bonus. Default 0
ongoing integer, -5 to 5 Persistent bonus. Default 0
rollingWith "Advantage" or "Disadvantage" Roll 3d6, keep the highest or lowest 2

result is strong_hit (10+), weak_hit (7–9) or miss (6 or less). details holds the inputs and diceTotal.

Root RPG (root-rpg)

2d6 + bonus with PbtA outcomes.

Input Type Notes
bonus integer, -3 to 5 Required
rollingWith "Advantage" or "Disadvantage" Roll 3d6, keep the highest or lowest 2

result is strong_hit (10+), weak_hit (7–9) or miss (6 or less).

Salvage Union (salvageunion)

A d20 looked up on one of the game’s roll tables. Higher is better on the Core Mechanic table.

Input Type Notes
tableName string Required, exact table name

Common tables: Core Mechanic, Group Initiative, Critical Injury, Critical Damage, Reactor Overload, Area Salvage, Mech Salvage, Reaction Roll, NPC Action, Morale, Retreat. There are many more (crawler, chimerium, character-creation tables); an unknown name returns an error.

Core Mechanic: 20 Nailed it, 11–19 Success, 6–10 Tough Choice, 2–5 Failure, 1 Cascade Failure.

result holds key (the table row), label, description (the table text to read out), tableName, table and roll.

Games without a shortcode

Any other system can still be rolled with plain notation and interpreted by hand, for example Shadowrun-style pools 12d6S{5}, World of Darkness 8d10S{8,1}, Savage Worlds trait dice 1d8!, or a D6 System wild die 5d6W.

The plugin collects no personal data. Its only network calls go to api.randsum.dev (the MCP server, or the HTTP API as a fallback) with the notation and game parameters of a roll, and /roll makes none. See the privacy policy.