Random Number Generator logo

Random Number Generator

Community
zazencodes

Production-ready MCP server that provides LLMs with essential random generation abilities, built entirely on Python's standard library.

Publisherzazencodes
Repositoryrandom-number-mcp
LanguagePython
Forks
6
Stars
50
Available tools
7
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Random Number Generator exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 7 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    50 stars and 6 forks from the linked repository.

Random Number MCP

Essential random number generation utilities from the Python standard library, including pseudorandom and cryptographically secure operations for integers, floats, weighted selections, list shuffling, and secure token generation.

Demo Video

https://github.com/user-attachments/assets/303a441a-2b10-47e3-b2a5-c8b51840e362

Tools

ToolPurposePython function
random_intGenerate random integersrandom.randint()
random_floatGenerate random floatsrandom.uniform()
random_choicesChoose items from a list (optional weights)random.choices()
random_shuffleReturn a new list with items shuffledrandom.sample()
random_sampleChoose k unique items from populationrandom.sample()
secure_token_hexGenerate cryptographically secure hex tokenssecrets.token_hex()
secure_random_intGenerate cryptographically secure integerssecrets.randbelow()

Setup

Claude Desktop

Add this to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

json
{
  "mcpServers": {
    "random-number": {
      "command": "uvx",
      "args": ["random-number-mcp"]
    }
  }
}

Tool Reference

random_int

Generate a random integer between low and high (inclusive).

Parameters:

  • low (int): Lower bound (inclusive)
  • high (int): Upper bound (inclusive)

Example:

json
{
  "name": "random_int",
  "arguments": {
    "low": 1,
    "high": 100
  }
}

random_float

Generate a random float between low and high.

Parameters:

  • low (float, optional): Lower bound (default: 0.0)
  • high (float, optional): Upper bound (default: 1.0)

Example:

json
{
  "name": "random_float",
  "arguments": {
    "low": 0.5,
    "high": 2.5
  }
}

random_choices

Choose k items from a population with replacement, optionally weighted.

Parameters:

  • population (list): List of items to choose from
  • k (int, optional): Number of items to choose (default: 1)
  • weights (list, optional): Weights for each item (default: equal weights)

Example:

json
{
  "name": "random_choices",
  "arguments": {
    "population": ["red", "blue", "green", "yellow"],
    "k": 2,
    "weights": [0.4, 0.3, 0.2, 0.1]
  }
}

random_shuffle

Return a new list with items in random order.

Parameters:

  • items (list): List of items to shuffle

Example:

json
{
  "name": "random_shuffle",
  "arguments": {
    "items": [1, 2, 3, 4, 5]
  }
}

random_sample

Choose k unique items from population without replacement.

Parameters:

  • population (list): List of items to choose from
  • k (int): Number of items to choose

Example:

json
{
  "name": "random_sample",
  "arguments": {
    "population": ["a", "b", "c", "d", "e"],
    "k": 2
  }
}

secure_token_hex

Generate a cryptographically secure random hex token.

Parameters:

  • nbytes (int, optional): Number of random bytes (default: 32)

Example:

json
{
  "name": "secure_token_hex",
  "arguments": {
    "nbytes": 16
  }
}

secure_random_int

Generate a cryptographically secure random integer below upper_bound.

Parameters:

  • upper_bound (int): Upper bound (exclusive)

Example:

json
{
  "name": "secure_random_int",
  "arguments": {
    "upper_bound": 1000
  }
}

Security Considerations

This package provides both standard pseudorandom functions (suitable for simulations, games, etc.) and cryptographically secure functions (suitable for tokens, keys, etc.):

  • Standard functions (random_int, random_float, random_choices, random_shuffle): Use Python's random module - fast but not cryptographically secure
  • Secure functions (secure_token_hex, secure_random_int): Use Python's secrets module - slower but cryptographically secure

Development

Prerequisites

  • Python 3.10+
  • uv package manager

Setup

bash
# Clone the repository
git clone https://github.com/example/random-number-mcp
cd random-number-mcp

# Install dependencies
uv sync --dev

# Run tests
uv run pytest

# Run linting
uv run ruff check --fix
uv run ruff format

# Type checking
uv run mypy src/

MCP Client Config

json
{
  "mcpServers": {
    "random-number-dev": {
      "command": "uv",
      "args": [
        "--directory",
        "<path_to_your_repo>/random-number-mcp",
        "run",
        "random-number-mcp"
      ]
    }
  }
}

Note: Replace <path_to_your_repo>/random-number-mcp with the absolute path to your cloned repository.

Building

bash
# Build package
uv build

# Test installation
uv run --with dist/*.whl random-number-mcp

Release Checklist

  1. Update Version:

    • Increment the version number in pyproject.toml, src/random_number_mcp/__init__.py, and server.json.
  2. Update Changelog:

    • Add a new entry in CHANGELOG.md for the release.

      • Draft notes with coding agent using git diff context.
      Update the @CHANGELOG.md for the latest release.
      List all significant changes, bug fixes, and new features.
      Here's the git diff:
      [GIT_DIFF]
    • Commit along with any other pending changes.

  3. Create GitHub Release:

    • Draft a new release on the GitHub UI.
      • Tag release using UI.
    • The GitHub workflow will automatically build and publish the package to PyPI.

Testing with MCP Inspector

For exploring and/or developing this server, use the MCP Inspector npm utility:

bash
# Install MCP Inspector
npm install -g @modelcontextprotocol/inspector

# Run local development server with the inspector
npx @modelcontextprotocol/inspector uv run random-number-mcp

# Run PyPI production server with the inspector
npx @modelcontextprotocol/inspector uvx random-number-mcp

MCP Registry

mcp-name: io.github.zazencodes/random-number-mcp

License

MIT License - see LICENSE file for details.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "random-number": {
      "command": "uvx",
      "args": [
        "random-number-mcp"
      ]
    }
  }
}

Available Tools

  • random_int

    Generate a random integer between low and high (inclusive).

    Args: low: Lower bound (inclusive) high: Upper bound (inclusive)

    Returns: Random integer between low and high

  • random_float

    Generate a random float between low and high.

    Args: low: Lower bound (default 0.0) high: Upper bound (default 1.0)

    Returns: Random float between low and high

  • random_choices

    Choose k items from population with replacement, optionally weighted.

    Args: population: List of items to choose from k: Number of items to choose (default 1) weights: Optional weights for each item (default None for equal weights)

    Returns: List of k chosen items

  • random_shuffle

    Return a new list with items in random order.

    Args: items: List of items to shuffle

    Returns: New list with items in random order

  • random_sample

    Choose k unique items from population without replacement.

    Args: population: List of items to choose from k: Number of items to choose

    Returns: List of k unique chosen items

  • secure_token_hex

    Generate a secure random hex token.

    Args: nbytes: Number of random bytes to generate (default 32)

    Returns: Hex string containing 2*nbytes characters

  • secure_random_int

    Generate a secure random integer below upper_bound.

    Args: upper_bound: Upper bound (exclusive)

    Returns: Random integer in range [0, upper_bound)

Use Random Number Generator MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Random Number Generator is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Random Number Generator as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Random Number Generator MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "random-number-generator": {
      "command": "npx",
      "args": [
        "-y",
        "random-number-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Random Number Generator MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Random Number Generator MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Random Number Generator to help me with this task?
Random Number Generator
Sure. I read it.
Here is what I found using Random Number Generator.

Frequently asked questions

What is the Random Number Generator MCP server used for?

Random Number Generator is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Random Number Generator MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Random Number Generator with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Random Number Generator MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Random Number Generator connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Random Number Generator MCP to TypingMind?

Random Number Generator runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Random Number Generator MCP provide in TypingMind?

Random Number Generator exposes 7 MCP tools that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Random Number Generator MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Random Number Generator requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇