Skip to main content
Glama
VeriTeknik

Pluggedin Random Number Generator

generate_random_integer

Generate cryptographically secure random integers within a user-defined range. Specify minimum, maximum, and count to produce reliable random numbers for various applications.

Instructions

Generate cryptographically secure random integers within a specified range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of random integers to generate
maxNoMaximum value (inclusive)
minNoMinimum value (inclusive)

Implementation Reference

  • The handler function for 'generate_random_integer' tool. Validates input parameters (min, max, count), generates cryptographically secure random integers using crypto.randomInt, and returns JSON-formatted results.
    private async generateRandomInteger(args: any) {
      const min = args.min ?? 0;
      const max = args.max ?? 100;
      const count = args.count ?? 1;
    
      if (min > max) {
        throw new Error("Minimum value cannot be greater than maximum value");
      }
    
      if (count < 1 || count > 1000) {
        throw new Error("Count must be between 1 and 1000");
      }
    
      const results: number[] = [];
      for (let i = 0; i < count; i++) {
        // Use Node.js crypto.randomInt for cryptographically secure random integers
        results.push(randomInt(min, max + 1));
      }
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              type: "random_integers",
              values: results,
              parameters: { min, max, count },
              timestamp: new Date().toISOString(),
            }, null, 2),
          },
        ],
      };
    }
  • Tool registration in ListToolsRequestSchema handler, including name, description, and detailed inputSchema for validation (min, max inclusive, count 1-1000).
    {
      name: "generate_random_integer",
      description: "Generate cryptographically secure random integers within a specified range",
      inputSchema: {
        type: "object",
        properties: {
          min: {
            type: "integer",
            description: "Minimum value (inclusive)",
            default: 0,
          },
          max: {
            type: "integer", 
            description: "Maximum value (inclusive)",
            default: 100,
          },
          count: {
            type: "integer",
            description: "Number of random integers to generate",
            default: 1,
            minimum: 1,
            maximum: 1000,
          },
        },
        required: [],
      },
    },
  • src/index.ts:249-250 (registration)
    Dispatch/registration in CallToolRequestSchema switch statement that routes calls to the generateRandomInteger handler.
    case "generate_random_integer":
      return await this.generateRandomInteger(args);
  • src/index.ts:46-241 (registration)
    Overall tool registration via ListToolsRequestSchema handler that lists all available tools including generate_random_integer.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "generate_random_integer",
            description: "Generate cryptographically secure random integers within a specified range",
            inputSchema: {
              type: "object",
              properties: {
                min: {
                  type: "integer",
                  description: "Minimum value (inclusive)",
                  default: 0,
                },
                max: {
                  type: "integer", 
                  description: "Maximum value (inclusive)",
                  default: 100,
                },
                count: {
                  type: "integer",
                  description: "Number of random integers to generate",
                  default: 1,
                  minimum: 1,
                  maximum: 1000,
                },
              },
              required: [],
            },
          },
          {
            name: "generate_random_float",
            description: "Generate cryptographically secure random floating-point numbers",
            inputSchema: {
              type: "object",
              properties: {
                min: {
                  type: "number",
                  description: "Minimum value (inclusive)",
                  default: 0.0,
                },
                max: {
                  type: "number",
                  description: "Maximum value (exclusive)",
                  default: 1.0,
                },
                count: {
                  type: "integer",
                  description: "Number of random floats to generate",
                  default: 1,
                  minimum: 1,
                  maximum: 1000,
                },
                precision: {
                  type: "integer",
                  description: "Number of decimal places to round to",
                  default: 6,
                  minimum: 1,
                  maximum: 15,
                },
              },
              required: [],
            },
          },
          {
            name: "generate_random_bytes",
            description: "Generate cryptographically secure random bytes",
            inputSchema: {
              type: "object",
              properties: {
                length: {
                  type: "integer",
                  description: "Number of random bytes to generate",
                  default: 32,
                  minimum: 1,
                  maximum: 1024,
                },
                encoding: {
                  type: "string",
                  description: "Output encoding format",
                  enum: ["hex", "base64", "binary"],
                  default: "hex",
                },
              },
              required: [],
            },
          },
          {
            name: "generate_uuid",
            description: "Generate a cryptographically secure UUID (v4)",
            inputSchema: {
              type: "object",
              properties: {
                count: {
                  type: "integer",
                  description: "Number of UUIDs to generate",
                  default: 1,
                  minimum: 1,
                  maximum: 100,
                },
                format: {
                  type: "string",
                  description: "UUID format",
                  enum: ["standard", "compact"],
                  default: "standard",
                },
              },
              required: [],
            },
          },
          {
            name: "generate_random_string",
            description: "Generate a cryptographically secure random string",
            inputSchema: {
              type: "object",
              properties: {
                length: {
                  type: "integer",
                  description: "Length of the random string",
                  default: 16,
                  minimum: 1,
                  maximum: 256,
                },
                charset: {
                  type: "string",
                  description: "Character set to use",
                  enum: ["alphanumeric", "alphabetic", "numeric", "hex", "base64", "ascii_printable"],
                  default: "alphanumeric",
                },
                count: {
                  type: "integer",
                  description: "Number of random strings to generate",
                  default: 1,
                  minimum: 1,
                  maximum: 100,
                },
              },
              required: [],
            },
          },
          {
            name: "generate_random_choice",
            description: "Randomly select items from a given list using cryptographically secure randomness",
            inputSchema: {
              type: "object",
              properties: {
                choices: {
                  type: "array",
                  description: "Array of items to choose from",
                  items: {
                    type: "string",
                  },
                  minItems: 1,
                },
                count: {
                  type: "integer",
                  description: "Number of items to select",
                  default: 1,
                  minimum: 1,
                },
                allow_duplicates: {
                  type: "boolean",
                  description: "Whether to allow duplicate selections",
                  default: true,
                },
              },
              required: ["choices"],
            },
          },
          {
            name: "generate_random_boolean",
            description: "Generate cryptographically secure random boolean values",
            inputSchema: {
              type: "object",
              properties: {
                count: {
                  type: "integer",
                  description: "Number of random booleans to generate",
                  default: 1,
                  minimum: 1,
                  maximum: 1000,
                },
                probability: {
                  type: "number",
                  description: "Probability of true (0.0 to 1.0)",
                  default: 0.5,
                  minimum: 0.0,
                  maximum: 1.0,
                },
              },
              required: [],
            },
          },
        ] as Tool[],
      };
    });
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/VeriTeknik/pluggedin-random-number-generator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server