Skip to main content
Glama
random-mcp

random-mcp

Random MCP

A local Python MCP server for pseudorandom sampling. Uses the official MCP Python SDK.

Install and run

Requires Python 3.10 or newer. From this directory:

python3 -m venv .venv
.venv/bin/python -m pip install -e '.[dev]'
.venv/bin/random-mcp

The server communicates over stdio and waits for an MCP client. It also supports python -m random_mcp from the environment where it is installed. On Windows, use .venv\Scripts\python.exe and .venv\Scripts\random-mcp.exe.

Configure your MCP host with an absolute path to the installed command:

{
  "mcpServers": {
    "random": {
      "command": "/absolute/path/to/random-mcp/.venv/bin/random-mcp",
      "args": []
    }
  }
}

Related MCP server: MCP Dice Roller

Tools

  • random_number() returns {"value": 0.375}: one uniform float in [0, 1).

  • random_interval(minimum, maximum, kind="float") returns {"value": ...}. Choose "integer" for whole numbers, with both endpoints included. Float sampling follows Python's random.uniform; rounding can include the upper endpoint. Equal bounds return that value. Reversed bounds, non-finite values, fractional integer bounds, and non-finite sampling results produce tool errors.

  • random_normal(mean=0, standard_deviation=1) returns {"value": ...} from a normal distribution. Both parameters must be finite; standard deviation must be positive. Non-finite results produce tool errors.

Values shown are examples. Sampling uses Python's standard pseudorandom generator, without public seed parameters. Each number call returns one sample.

Dice

roll_dice(expression, detail="auto") accepts NdM, such as 1d10, 2d10, or 100d10, and sums such as 1d10 + 2d100 + 5d4. Each die is sampled independently from 1 through M, inclusive. Whitespace, uppercase D, and leading zeros are accepted. Counts and sides must be positive integers. Only addition is supported: modifiers, subtraction, multiplication, and parentheses are rejected. Terms remain in input order.

  • auto: include individual rolls for up to 100 total dice; use compact above 100.

  • full: always include individual rolls.

  • compact: return aggregates without individual rolls or roll arrays in memory.

For example, roll_dice("1000d4") returns this shape (totals vary):

{
  "expression": "1000d4",
  "detail": "compact",
  "total_dice": 1000,
  "total": 2500,
  "terms": [{"count": 1000, "sides": 4, "subtotal": 2500}]
}

Full mode adds a rolls array to each term. Auto considers the total count across all terms. Limits are 10,000 total dice, 100 terms, 1,000,000 sides per die, and 10,000 expression characters. Invalid requests return tool errors before any dice are rolled.

Development

Install the development tools with python -m pip install -e '.[dev]' using the virtual environment's Python. Run all checks before committing:

.venv/bin/python -m ruff check .
.venv/bin/python -m ruff format --check .
.venv/bin/python -m mypy
.venv/bin/python -m pytest

Apply automatic lint fixes and formatting with:

.venv/bin/python -m ruff check --fix .
.venv/bin/python -m ruff format .

Ruff checks application code and tests for common errors, import ordering, and consistent formatting, with Python 3.10 as the target. Mypy runs in strict mode on src; pytest covers sampling, dice parsing, MCP validation, and stdio calls. Tool settings live in pyproject.toml.

Features are delivered in five commits: uniform sampling, intervals, normal sampling, simple dice, then compound dice. Each stage includes tests and docs.

Available Tools

4 tools
random_intervalA

Sample uniformly between bounds; kind='integer' includes both endpoints.

Float sampling can include the upper bound through rounding. Equal bounds return that value. Integer bounds must be whole numbers.

Inputs: maximum (required), minimum (required), kind. Returns: value

random_normalA

Return one normal sample; defaults to mean 0 and standard deviation 1.

Parameters must be finite and standard_deviation must be positive.

Inputs: mean, standard_deviation. Returns: value

random_numberA

Return one uniformly distributed random float in [0, 1).

Inputs: no named parameters. Returns: value

roll_diceA

Roll NdM dice or sums, such as 2d10 or 1d10 + 2d100 + 5d4.

Return count, sides, subtotal per term and a grand total. Full detail also includes every roll; compact omits rolls. Auto uses compact above 100 dice. Only addition is supported; no modifiers, subtraction, or parentheses. Limits: 10,000 total dice, 100 terms, 1,000,000 sides per die, and 10,000 expression characters.

Inputs: expression (required), detail. Returns: terms, total, detail, expression, +1 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool targets a distinct distribution or use case: uniform float, bounded interval, normal, and dice notation. random_number and random_interval overlap conceptually since random_number is a special case of uniform sampling, but the descriptions clarify the intended difference.

    Naming Consistency4/5

    Three tools follow a consistent random_noun pattern, while roll_dice breaks the pattern with a verb_noun style. The naming is still predictable and readable, but the one deviation keeps it from a perfect score.

    Tool Count5/5

    Four tools is a well-scoped size for a random number generation server. Each tool serves a common random sampling need without unnecessary bloat.

    Completeness4/5

    The set covers standard uniform, bounded interval, normal, and dice-style generation, which covers most common use cases. Minor gaps like seeding or random choice are absent but not critical for the apparent purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Production-ready MCP server that provides LLMs with essential random generation abilities, including random integers, floats, choices, shuffling, and cryptographically secure tokens.
      7
      50
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that provides tools for rolling dice using standard notation, flipping coins, and selecting random items from lists. It supports advanced tabletop gaming features such as character stat generation and keep-highest/lowest mechanics.
      6
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A random number generation MCP server hosted on Cloudflare Workers that provides tools for generating integers, floats, weighted choices, and samples from various probability distributions, usable from MCP clients like Notion AI.
      MIT