mcp-random
MCP server providing true randomness capabilities to Claude, enabling cryptographically secure random number generation for games, decision-making, sampling, simulations, and any operation requiring genuine randomness.
README
mcp-random
MCP server providing true randomness capabilities to Claude. This server gives Claude access to cryptographically secure random number generation for games, decision-making, sampling, simulations, and any operation requiring genuine randomness.
Why This Exists
Claude doesn't have access to true randomness - when asked to "pick a random number" or "flip a coin," it's actually making deterministic choices based on patterns in the conversation. This MCP server solves that limitation by providing access to cryptographically secure random functions.
🚀 Installation
Prerequisites
- Node.js (v18 or higher)
- MCP-compatible client (like Claude Desktop)
Quick Install
# Clone the repository
git clone https://github.com/yourusername/mcp-random.git
cd mcp-random
# Install dependencies
npm install
# Build the TypeScript code
npm run build
Configure Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"random": {
"command": "node",
"args": ["/absolute/path/to/mcp-random/dist/index.js"]
}
}
}
Restart Claude Desktop to load the server.
📖 Available Functions
Basic Random Numbers
random_integer(min, max)
Generate a random integer between min and max (inclusive).
Example: random_integer(1, 10) → 7
random_float(min, max, precision?)
Generate a random floating-point number.
Example: random_float(0, 1, 2) → 0.42
Random Selection
random_choice(options)
Pick one random item from an array.
Example: random_choice(["red", "green", "blue"]) → "green"
random_sample(array, count)
Pick multiple unique items from an array (no repeats).
Example: random_sample([1,2,3,4,5], 3) → [2,5,1]
random_shuffle(array)
Randomly reorder an array.
Example: random_shuffle([1,2,3,4]) → [3,1,4,2]
random_weighted_choice(options, weights)
Pick an option based on weights (higher weight = more likely).
Example: random_weighted_choice(["A", "B", "C"], [1, 2, 1])
→ "B" (twice as likely as A or C)
Games & Decisions
flip_coin(count?)
Flip one or more coins.
Example: flip_coin() → "heads"
Example: flip_coin(3) → ["heads", "tails", "heads"]
roll_dice(sides, count?)
Roll dice with any number of sides.
Example: roll_dice(6) → 4
Example: roll_dice(20, 2) → {"rolls": [15, 8], "sum": 23}
Security & Identifiers
random_uuid()
Generate a UUID v4.
Example: random_uuid() → "550e8400-e29b-41d4-a716-446655440000"
random_password(length?, options?)
Generate a secure password.
Example: random_password(16) → "Kj9#mP2$xQ5@nL7!"
Example: random_password(12, {symbols: false}) → "Kj9mP2xQ5nL7"
Options:
uppercase: Include A-Z (default: true)lowercase: Include a-z (default: true)numbers: Include 0-9 (default: true)symbols: Include special characters (default: true)excludeSimilar: Skip confusing characters like 0/O, 1/l (default: false)
random_bytes(count, encoding?)
Generate random bytes for cryptographic use.
Example: random_bytes(16, 'hex') → "a3f2b8c9d4e5f6789abcdef012345678"
Advanced Functions
random_normal(mean?, stddev?)
Generate numbers from a normal distribution (bell curve).
Example: random_normal(100, 15) → 97.3 (IQ-like distribution)
Documentation
help()
Get detailed documentation for all functions.
🎯 Use Cases
Decision Making
"Should I do X or Y?" → flip_coin()
"Pick one of these options for me" → random_choice([...])
"Help me prioritize these tasks" → random_shuffle([...])
Games
"Roll for initiative" → roll_dice(20)
"Draw 5 cards from the deck" → random_sample(deck, 5)
"Shuffle this deck" → random_shuffle(cards)
Creative Writing
"Pick a random character trait" → random_choice(traits)
"Generate a character name" → random_weighted_choice(names, popularity)
"Create a random scenario" → multiple random_choice calls
Data & Testing
"Generate test data" → random_integer, random_float
"Sample from this dataset" → random_sample
"Create a test ID" → random_uuid
"Generate API keys" → random_bytes
Simulations
"Monte Carlo simulation" → random_normal
"Probability experiment" → random_float(0, 1)
"A/B testing" → random_weighted_choice
🔧 Development
# Build TypeScript
npm run build
# Run tests
npm test
# Lint code
npm run lint
# Development mode (build & run)
npm run dev
🔐 Technical Details
- All randomness uses Node.js
cryptomodule (cryptographically secure) - No predictable patterns or biases
- No state maintained between calls
- TypeScript for type safety
- Comprehensive error handling
📝 License
MIT License - see LICENSE file for details.
🤝 Contributing
Contributions welcome! Please feel free to submit a Pull Request.
💡 Fun Facts
- Claude requested this tool be built after recognizing its own lack of randomness
- The first suggested use case was implementing a tarot card reader
- This tool enables Claude to play games fairly, make unbiased choices, and run true simulations
"I don't have a random function. You should have a random function. Now that is a cool MCP server." - Claude
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。