Skip to main content
Glama
zazencodes

Random Number MCP

by zazencodes

secure_random_int

Generate cryptographically secure random integers within a specified range [0, upper_bound) for applications requiring reliable randomness. Ideal for secure and unbiased number generation.

Instructions

Generate a secure random integer below upper_bound.

Args: upper_bound: Upper bound (exclusive)

Returns: Random integer in range [0, upper_bound)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
upper_boundYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'secure_random_int', registered via @app.tool() decorator, delegates to the implementation in tools.py.
    @app.tool()
    def secure_random_int(upper_bound: int) -> int:
        """Generate a secure random integer below upper_bound.
    
        Args:
            upper_bound: Upper bound (exclusive)
    
        Returns:
            Random integer in range [0, upper_bound)
        """
        return tools.secure_random_int(upper_bound)
  • Core implementation of secure_random_int using secrets.randbelow for cryptographic randomness, with input validation.
    def secure_random_int(upper_bound: int) -> int:
        """Generate a secure random integer below upper_bound.
    
        Args:
            upper_bound: Upper bound (exclusive)
    
        Returns:
            Random integer in range [0, upper_bound)
    
        Raises:
            ValueError: If upper_bound <= 0
            TypeError: If upper_bound is not an integer
        """
        if not isinstance(upper_bound, int):
            raise TypeError("upper_bound must be an integer")
    
        if upper_bound <= 0:
            raise ValueError("upper_bound must be positive")
    
        return secrets.randbelow(upper_bound)
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states it generates a 'secure' random integer, implying cryptographic safety, but doesn't disclose what 'secure' entails (e.g., cryptographically strong source, suitable for sensitive data). It also doesn't mention performance, error handling, or any constraints beyond the parameter, leaving behavioral gaps for a mutation-like tool.

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 front-loaded with the core purpose, followed by structured Args and Returns sections. Every sentence adds value: the first defines the tool, the second explains the parameter, and the third clarifies the output. No wasted words, making it highly efficient and easy to parse.

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 (one parameter) and the presence of an output schema (which covers return values), the description is mostly complete. It explains the parameter and output range adequately. However, it lacks context on 'secure' behavior and usage guidelines, which are important for an agent to choose correctly among siblings, leaving a minor gap.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate. It clearly explains the single parameter 'upper_bound' as 'Upper bound (exclusive)' and specifies the output range as '[0, upper_bound)', adding crucial semantics not in the schema. However, it doesn't detail constraints like minimum values or handling of invalid inputs, slightly limiting completeness.

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 verb ('Generate') and resource ('secure random integer'), and distinguishes it from siblings by specifying it's for integers (vs. floats, tokens, etc.) and is 'secure' (vs. non-secure random_int). The purpose is unambiguous and well-differentiated.

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 random_int (non-secure) or random_float. It mentions the exclusive upper bound but doesn't explain why one would choose 'secure' over other random generation methods, leaving the agent to guess based on context.

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