MCP-Rand is a Model Context Protocol server that provides various random generation utilities including UUID generation, random numbers, strings, passwords, Gaussian distribution, dice rolling, and card drawing. It can be integrated with MCP clients to add randomization capabilities to your applications.
You can install the package using npm:
npm install mcp-rand
Or install it globally:
npm install -g mcp-rand
To run the server as a CLI tool:
npx mcp-rand
Add the server to your MCP client configuration:
{
"mcpServers": {
"mcp-rand": {
"command": "node",
"args": ["path/to/mcp-rand/build/index.js"],
"disabled": false,
"alwaysAllow": []
}
}
}
Generates RFC 4122 version 4 UUIDs:
const uuid = await client.callTool('generate_uuid', {});
console.log(uuid); // e.g., "550e8400-e29b-41d4-a716-446655440000"
Generates random numbers within a specified range:
const number = await client.callTool('generate_random_number', {
min: 1,
max: 100
});
console.log(number); // e.g., 42
Generates random numbers following a Gaussian (normal) distribution:
const gaussian = await client.callTool('generate_gaussian', {});
console.log(gaussian); // e.g., 0.6827
Generates random strings with configurable length and character sets:
const string = await client.callTool('generate_string', {
length: 15,
charset: 'alphanumeric'
});
console.log(string); // e.g., "aB9cD8eF7gH6iJ5"
Supported character sets:
Generates strong passwords with a mix of character types:
const password = await client.callTool('generate_password', {
length: 20
});
console.log(password); // e.g., "aB9#cD8$eF7@gH6*iJ5"
Note: While passwords are generated locally, it's recommended to use a dedicated password manager.
Roll multiple dice using standard dice notation:
const rolls = await client.callTool('roll_dice', {
dice: ['2d6', '1d20', '4d4']
});
console.log(rolls);
/* Output example:
[
{
"dice": "2d6",
"rolls": [3, 1],
"total": 4
},
{
"dice": "1d20",
"rolls": [4],
"total": 4
},
{
"dice": "4d4",
"rolls": [2, 3, 2, 3],
"total": 10
}
]
*/
Draw cards from a standard 52-card deck:
// Initial draw
const draw1 = await client.callTool('draw_cards', {
count: 5
});
console.log(draw1);
/* Output example:
{
"drawnCards": [
{ "suit": "hearts", "value": "A" },
{ "suit": "diamonds", "value": "7" },
{ "suit": "clubs", "value": "K" },
{ "suit": "spades", "value": "2" },
{ "suit": "hearts", "value": "10" }
],
"remainingCount": 47,
"deckState": "t//+///bDw=="
}
*/
// Draw more cards using previous deck state
const draw2 = await client.callTool('draw_cards', {
count: 3,
deckState: draw1.deckState
});
console.log(draw2);
/* Output example:
{
"drawnCards": [
{ "suit": "diamonds", "value": "Q" },
{ "suit": "clubs", "value": "5" },
{ "suit": "spades", "value": "J" }
],
"remainingCount": 44,
"deckState": "l//+//zbDw=="
}
*/
The card drawer maintains the deck state between draws using base64 encoding, properly shuffles available cards before each draw, and returns both the drawn cards and the remaining deck state.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-rand" '{"command":"node","args":["path/to/mcp-rand/build/index.js"],"disabled":false,"alwaysAllow":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-rand": {
"command": "node",
"args": [
"path/to/mcp-rand/build/index.js"
],
"disabled": false,
"alwaysAllow": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-rand": {
"command": "node",
"args": [
"path/to/mcp-rand/build/index.js"
],
"disabled": false,
"alwaysAllow": []
}
}
}
3. Restart Claude Desktop for the changes to take effect