Skip to main content
Glama
zazencodes

Random Number MCP

by zazencodes

random_int

Generate a random integer within a specified range using predefined lower and upper bounds. Ideal for scenarios requiring precise integer randomization in LLM workflows.

Instructions

Generate a random integer between low and high (inclusive).

Args: low: Lower bound (inclusive) high: Upper bound (inclusive)

Returns: Random integer between low and high

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
highYes
lowYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • FastMCP handler for the 'random_int' tool. Defines the tool schema via type annotations and documentation string. Executes the tool by delegating to the implementation in tools.py.
    @app.tool()
    def random_int(low: int, high: int) -> int:
        """Generate a random integer between low and high (inclusive).
    
        Args:
            low: Lower bound (inclusive)
            high: Upper bound (inclusive)
    
        Returns:
            Random integer between low and high
        """
        return tools.random_int(low, high)
  • Core implementation of the random_int logic, performing input validation and generating the random integer using random.randint.
    def random_int(low: int, high: int) -> int:
        """Generate a random integer between low and high (inclusive).
    
        Args:
            low: Lower bound (inclusive)
            high: Upper bound (inclusive)
    
        Returns:
            Random integer between low and high
    
        Raises:
            ValueError: If low > high
            TypeError: If inputs are not integers
        """
        if not isinstance(low, int) or not isinstance(high, int):
            raise TypeError("Both low and high must be integers")
    
        validate_range(low, high)
        return random.randint(low, high)
  • Utility function used by random_int to validate that the low bound is less than or equal to the high bound.
    def validate_range(low: int | float, high: int | float) -> None:
        """Validate that low <= high for range-based functions."""
        if low > high:
            raise ValueError(f"Low value ({low}) must be <= high value ({high})")
  • The @app.tool() decorator registers 'random_int' as an MCP tool.
    @app.tool()
    def random_int(low: int, high: int) -> int:
        """Generate a random integer between low and high (inclusive).
    
        Args:
            low: Lower bound (inclusive)
            high: Upper bound (inclusive)
    
        Returns:
            Random integer between low and high
        """
        return tools.random_int(low, high)
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. It discloses the inclusive bounds behavior and return type, which are essential behavioral traits. However, it doesn't mention distribution characteristics (e.g., uniform), performance, or error handling for invalid inputs like low > high.

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

Conciseness4/5

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

The description is appropriately sized with a clear purpose statement followed by structured Args and Returns sections. Every sentence earns its place, though the formatting could be slightly more front-loaded by integrating the bounds explanation into the first sentence.

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

Completeness4/5

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

Given the tool's low complexity, 2 parameters with full semantic coverage in the description, and an output schema (implied by 'Returns'), the description is nearly complete. It explains what the tool does, parameter meanings, and return value, though it lacks some behavioral details like error cases.

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

Parameters5/5

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

The schema has 0% description coverage, so the description fully compensates by clearly explaining both parameters (low and high) with their inclusive semantics. It adds crucial meaning beyond the bare schema types, specifying the inclusive bounds and their roles.

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 specific action ('Generate a random integer') and resource (integer between bounds), and distinguishes from siblings by specifying the exact type of random generation (integer vs. float, choices, etc.). The verb+resource combination is precise and unambiguous.

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 through the parameter explanation (bounds for integer generation), but doesn't explicitly state when to use this tool versus alternatives like random_float or secure_random_int. There's no guidance on scenarios where this tool is preferred over siblings.

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/zazencodes/random-number-mcp'

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