Random Generation MCP server

Provides diverse random generation utilities including UUIDs, numbers, strings, passwords, and more.
Back to servers
Setup instructions
Provider
Michael Darmousseh
Release date
Jan 11, 2025
Language
TypeScript
Package
Stats
1.8K downloads
3 stars

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.

Installation

You can install the package using npm:

npm install mcp-rand

Or install it globally:

npm install -g mcp-rand

Usage

As a CLI Tool

To run the server as a CLI tool:

npx mcp-rand

Integration with MCP Clients

Add the server to your MCP client configuration:

{
  "mcpServers": {
    "mcp-rand": {
      "command": "node",
      "args": ["path/to/mcp-rand/build/index.js"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

Features and Examples

UUID Generator

Generates RFC 4122 version 4 UUIDs:

const uuid = await client.callTool('generate_uuid', {});
console.log(uuid); // e.g., "550e8400-e29b-41d4-a716-446655440000"

Random Number Generator

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

Gaussian Random Generator

Generates random numbers following a Gaussian (normal) distribution:

const gaussian = await client.callTool('generate_gaussian', {});
console.log(gaussian); // e.g., 0.6827

Random String Generator

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:

  • alphanumeric (default): A-Z, a-z, 0-9
  • numeric: 0-9
  • lowercase: a-z
  • uppercase: A-Z
  • special: !@#$%^&*()_+-=[]{};'"|,.<>/?

Password Generator

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.

Dice Roller

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
  }
]
*/

Card Drawer

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.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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": []
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later