Skip to main content
Glama

generate_random_boolean

Generate cryptographically secure random boolean values with customizable counts and probability settings. Ideal for simulations, testing, and decision-making applications.

Instructions

Generate cryptographically secure random boolean values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of random booleans to generate
probabilityNoProbability of true (0.0 to 1.0)

Implementation Reference

  • The core handler function implementing the generate_random_boolean tool. It generates an array of random booleans using Node.js crypto.randomBytes for cryptographic security, respecting count and probability parameters, and returns a structured JSON response.
    private async generateRandomBoolean(args: any) { const count = args.count ?? 1; const probability = args.probability ?? 0.5; if (count < 1 || count > 1000) { throw new Error("Count must be between 1 and 1000"); } if (probability < 0.0 || probability > 1.0) { throw new Error("Probability must be between 0.0 and 1.0"); } const results: boolean[] = []; for (let i = 0; i < count; i++) { const randomBuffer = randomBytes(4); const randomValue = randomBuffer.readUInt32BE(0) / 0xFFFFFFFF; results.push(randomValue < probability); } return { content: [ { type: "text", text: JSON.stringify({ type: "random_booleans", values: results, parameters: { count, probability }, timestamp: new Date().toISOString(), }, null, 2), }, ], }; }
  • Input schema definition for the generate_random_boolean tool, specifying parameters for count (1-1000) and probability (0.0-1.0) with defaults.
    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: [], },
  • src/index.ts:215-238 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema for generate_random_boolean.
    { 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: [], }, },
  • src/index.ts:261-262 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement, routing calls to generate_random_boolean to the handler method.
    case "generate_random_boolean": return await this.generateRandomBoolean(args);

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