Skip to main content
Glama
VeriTeknik

Pluggedin Random Number Generator

generate_random_choice

Select random items from a list with cryptographically secure randomness. Define the number of choices and allow duplicates for customizable, unbiased results.

Instructions

Randomly select items from a given list using cryptographically secure randomness

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allow_duplicatesNoWhether to allow duplicate selections
choicesYesArray of items to choose from
countNoNumber of items to select

Implementation Reference

  • The primary handler function that executes the generate_random_choice tool logic. It validates input parameters, generates random selections from the choices array using cryptographically secure randomInt, supports optional duplicates, and returns a standardized JSON response.
    private async generateRandomChoice(args: any) {
      const choices = args.choices;
      const count = args.count ?? 1;
      const allowDuplicates = args.allow_duplicates ?? true;
    
      if (!Array.isArray(choices) || choices.length === 0) {
        throw new Error("Choices must be a non-empty array");
      }
    
      if (count < 1) {
        throw new Error("Count must be at least 1");
      }
    
      if (!allowDuplicates && count > choices.length) {
        throw new Error("Count cannot exceed choices length when duplicates are not allowed");
      }
    
      const results: string[] = [];
      const availableChoices = [...choices];
    
      for (let i = 0; i < count; i++) {
        const randomIndex = randomInt(0, availableChoices.length);
        const selected = availableChoices[randomIndex];
        results.push(selected);
    
        if (!allowDuplicates) {
          availableChoices.splice(randomIndex, 1);
        }
      }
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              type: "random_choices",
              values: results,
              parameters: { choices, count, allow_duplicates: allowDuplicates },
              timestamp: new Date().toISOString(),
            }, null, 2),
          },
        ],
      };
    }
  • Input schema and metadata definition for the generate_random_choice tool, used for validation and documentation in the tools list.
      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"],
      },
    },
  • src/index.ts:259-260 (registration)
    Registration in the tool dispatch switch statement within the CallToolRequestSchema handler, routing calls to the handler method.
    case "generate_random_choice":
      return await this.generateRandomChoice(args);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context by specifying 'cryptographically secure randomness,' which informs the agent about the quality and security of the randomness, though it lacks details on error handling, performance, or output format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that is front-loaded with the core functionality and includes a key behavioral detail ('cryptographically secure randomness') without any wasted words or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is somewhat complete but lacks details on output format, error cases, or practical examples, which could help the agent use it more effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (choices, count, allow_duplicates). The description does not add any meaning beyond what the schema provides, such as explaining interactions between parameters or usage examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('select') and resource ('items from a given list'), and it distinguishes itself from siblings by focusing on list-based random selection rather than generating specific data types like booleans, bytes, floats, integers, strings, or UUIDs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for random selection from lists, but it does not explicitly state when to use this tool versus alternatives like generate_random_string or generate_random_integer, nor does it provide exclusions or prerequisites for use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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