Skip to main content
Glama
turlockmike

MCP Rand

by turlockmike

generate_random_number

Generate a random number within a user-defined range using the MCP Rand server. Specify minimum and maximum values to produce inclusive results efficiently.

Instructions

Generate a random number within a specified range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxNoMaximum value (inclusive). Defaults to 100.
minNoMinimum value (inclusive). Defaults to 0.

Implementation Reference

  • The handler function that implements the generate_random_number tool logic, generating a random integer between min (default 0) and max (default 100).
    export const generateRandomNumberHandler = async (
      request: CallToolRequest
    ): Promise<CallToolResult> => {
      const args = request.params.arguments as { min?: number; max?: number };
      const min = args.min ?? 0;
      const max = args.max ?? 100;
    
      if (min > max) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Min value cannot be greater than max value'
        );
      }
    
      // Generate random number between min and max (inclusive)
      const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
      
      return {
        content: [
          {
            type: 'text',
            text: randomNumber.toString()
          }
        ]
      };
    };
  • Tool specification defining the name, description, and input schema (min and max numbers) for the generate_random_number tool.
    export const toolSpec = {
      name: 'generate_random_number',
      description: 'Generate a random number within a specified range',
      inputSchema: {
        type: 'object' as const,
        properties: {
          min: {
            type: 'number',
            description: 'Minimum value (inclusive). Defaults to 0.',
          },
          max: {
            type: 'number',
            description: 'Maximum value (inclusive). Defaults to 100.',
          },
        },
      }
    };
  • src/index.ts:20-20 (registration)
    Registers the generateRandomNumberHandler for the 'generate_random_number' tool in the MCP server registry.
    registry.register('tools/call', 'generate_random_number', generateRandomNumberHandler as Handler);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the range constraint but doesn't describe distribution (uniform vs other), whether the number is integer or float, what happens with invalid inputs, or any performance/rate limit considerations. For a random number generator with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 wasted words. It's appropriately sized for a simple tool and front-loads the essential information. Every word earns its place in conveying the core functionality.

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?

For a simple 2-parameter tool with 100% schema coverage but no annotations and no output schema, the description provides basic context but leaves gaps. It doesn't explain the return value format (integer vs float, precision), doesn't address distribution characteristics, and doesn't help differentiate from similar sibling tools. The description is minimally adequate but could be more complete given the tool's context.

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%, with both parameters (min and max) fully documented in the schema. The description adds the concept of 'range' which is already implied by having min and max parameters. It doesn't provide additional syntax, format, or constraint details beyond what the schema already specifies. Baseline 3 is appropriate when schema does the heavy lifting.

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 action ('generate') and resource ('random number') with scope ('within a specified range'). It distinguishes from some siblings like generate_password or generate_uuid but doesn't explicitly differentiate from generate_gaussian or roll_dice which also produce random numbers. The purpose is specific but sibling differentiation is incomplete.

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?

No guidance is provided about when to use this tool versus alternatives like generate_gaussian (for normal distribution), roll_dice (for discrete integer outcomes), or other random generation siblings. The description only states what it does, not when it's appropriate compared to other tools in the server.

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/turlockmike/mcp-rand'

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