Generate Secure Random Numbers and Tokens
Generate random integers, floats, weighted choices, shuffles, and cryptographically secure tokens - built on Python's stdlib.
Why it matters
Leverage Python's standard library for robust random number generation, including pseudorandom and cryptographically secure options for integers, floats, sampling, and token creation.
Outcomes
What it gets done
Generate pseudorandom integers and floats.
Create cryptographically secure random integers and hex tokens.
Perform weighted sampling, list shuffling, and unique element selection.
Integrate seamlessly with Python projects for diverse applications.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-random-number | bash Capabilities
Tools your agent gets
Generate random integers within a specified range
Generate random floating-point numbers within a specified range
Select elements from a list with optional weights for weighted sampling
Return a new list with shuffled elements in random order
Select k unique elements from a population without replacement
Generate cryptographically secure hexadecimal tokens
Generate cryptographically secure random integers
Overview
Random Number MCP Server
Random Number MCP Server provides Python stdlib-based random generation - pseudorandom integers, floats, weighted choices, and shuffles via the random module, plus cryptographically secure tokens and integers via the secrets module. Use pseudorandom tools for simulations and games; use secure_token_hex/secure_random_int instead whenever the output needs to resist prediction, such as tokens or codes.
What it does
Random Number MCP Server provides random number generation utilities from Python's standard library, covering both fast pseudorandom operations (integers, floats, weighted sampling, list shuffling) and cryptographically secure operations (secure tokens, secure random integers).
When to use - and when NOT to
Use pseudorandom tools (random_int, random_float, random_choices, random_shuffle, random_sample) for simulations, games, or any non-security-sensitive randomness need - they're fast but not cryptographically safe. Use the secure tools (secure_token_hex, secure_random_int) instead whenever the output needs to resist prediction - session tokens, password reset codes, or other security-critical values - since they're built on Python's secrets module rather than random. Do not use the pseudorandom tools for anything security-sensitive; they explicitly are not cryptographically secure.
Capabilities
random_int: generate a random integer within a range.random_float: generate a random floating-point number within a range.random_choices: pick items from a list, with optional weights.random_shuffle: return a new list with elements shuffled.random_sample: pick k unique elements from a population without replacement.secure_token_hex: generate a cryptographically secure hex token.secure_random_int: generate a cryptographically secure random integer.
How to install
uvx random-number-mcp
Configure Claude Desktop:
{
"mcpServers": {
"random-number": {
"command": "uvx",
"args": ["random-number-mcp"]
}
}
}
For local development: git clone https://github.com/example/random-number-mcp && cd random-number-mcp && uv sync --dev, then debug with npx @modelcontextprotocol/inspector uv run random-number-mcp. Requires Python 3.10+ and the uv package manager.
Who it's for
Developers who need an AI assistant to generate random values for simulations, games, sampling, or security-sensitive tokens, choosing the right tool (pseudorandom vs. cryptographically secure) for the use case.
Source README
Essential utilities for generating random numbers from Python's standard library, including pseudorandom and cryptographically secure operations for integers, floating-point numbers, weighted sampling, list shuffling, and secure token generation.
Installation
UVX
uvx random-number-mcp
Development Setup
git clone https://github.com/example/random-number-mcp
cd random-number-mcp
uv sync --dev
MCP Inspector - Local Development
npx @modelcontextprotocol/inspector uv run random-number-mcp
MCP Inspector - Production
npx @modelcontextprotocol/inspector uvx random-number-mcp
Configuration
Claude Desktop
{
"mcpServers": {
"random-number": {
"command": "uvx",
"args": ["random-number-mcp"]
}
}
}
Development Configuration
{
"mcpServers": {
"random-number-dev": {
"command": "uv",
"args": [
"--directory",
"<path_to_your_repo>/random-number-mcp",
"run",
"random-number-mcp"
]
}
}
}
Available Tools
| Tool | Description |
|---|---|
random_int |
Generate random integers |
random_float |
Generate random floating-point numbers |
random_choices |
Select elements from a list (with optional weights) |
random_shuffle |
Return a new list with shuffled elements |
random_sample |
Select k unique elements from a population |
secure_token_hex |
Generate cryptographically secure hex tokens |
secure_random_int |
Generate cryptographically secure integers |
Features
- Pseudorandom number generation for integers and floating-point numbers
- Weighted random selection from lists
- List shuffling and sampling without replacement
- Cryptographically secure token generation
- Cryptographically secure random integers
- Built entirely on Python's standard library (random and secrets modules)
- Suitable for both simulations/games and security-critical applications
Usage Examples
Generate a random integer between 1 and 100
Generate a random floating-point number between 0.5 and 2.5
Select 2 elements from a list with custom weights
Randomly shuffle a list of elements
Select 2 unique elements from a population
Resources
Notes
This package provides both standard pseudorandom functions (fast but not cryptographically secure) and secure functions (slower but cryptographically secure). Requires Python 3.10+ and uses the uv package manager for development.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.