Skip to main content
Glama
VeriTeknik

Pluggedin Random Number Generator

generate_random_string

Create cryptographically secure random strings with customizable length, character set, and count for enhanced data security and flexibility.

Instructions

Generate a cryptographically secure random string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
charsetNoCharacter set to usealphanumeric
countNoNumber of random strings to generate
lengthNoLength of the random string

Implementation Reference

  • The core handler function implementing the generate_random_string tool logic, generating cryptographically secure random strings using Node.js crypto.randomInt from specified character sets.
    private async generateRandomString(args: any) {
      const length = args.length ?? 16;
      const charset = args.charset ?? "alphanumeric";
      const count = args.count ?? 1;
    
      if (length < 1 || length > 256) {
        throw new Error("Length must be between 1 and 256");
      }
    
      if (count < 1 || count > 100) {
        throw new Error("Count must be between 1 and 100");
      }
    
      const charsets = {
        alphanumeric: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        alphabetic: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
        numeric: "0123456789",
        hex: "0123456789abcdef",
        base64: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
        ascii_printable: "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
      };
    
      const chars = charsets[charset as keyof typeof charsets];
      if (!chars) {
        throw new Error(`Invalid charset: ${charset}`);
      }
    
      const results: string[] = [];
      for (let i = 0; i < count; i++) {
        let result = "";
        for (let j = 0; j < length; j++) {
          const randomIndex = randomInt(0, chars.length);
          result += chars[randomIndex];
        }
        results.push(result);
      }
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              type: "random_strings",
              values: results,
              parameters: { length, charset, count },
              timestamp: new Date().toISOString(),
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:156-185 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the tool name, description, and input schema.
    {
      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: [],
      },
    },
  • Input schema validation for the generate_random_string tool parameters.
    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: [],
  • Dispatch case in CallToolRequestSchema handler that routes to the generateRandomString implementation.
    case "generate_random_string":
      return await this.generateRandomString(args);
Behavior3/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 specifies 'cryptographically secure,' which adds important context about security properties beyond basic randomness. However, it doesn't mention performance, rate limits, or error conditions, leaving gaps for a tool that generates secure data.

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 with zero waste. It's front-loaded with the core purpose and includes a key behavioral detail ('cryptographically secure'), making it appropriately sized and easy to parse.

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 minimally complete. It covers the core purpose and security aspect but lacks usage guidance, error handling, or output format details, which could help an 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?

The input schema has 100% description coverage, with clear documentation for charset, count, and length. The description adds no parameter-specific information beyond what the schema provides, so it meets the baseline of 3 for adequate but not enhanced parameter semantics.

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

Purpose4/5

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

The description clearly states the verb ('generate') and resource ('cryptographically secure random string'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like generate_random_bytes or generate_random_choice, which also generate random data but with different outputs or constraints.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like generate_random_bytes (for raw bytes) or generate_random_choice (for selecting from a list). It lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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