Skip to main content
Glama

generate_basic_random

Generate a random integer within a specified range for applications like lottery systems, game randomness, ID generation, or test data creation. Customize with optional salt, minimum, and maximum values.

Instructions

Basic Random Number Generator

Generate a random integer within the specified range

Args:
    salt (str, optional): Random number salt value for increased randomness. Defaults to "".
    min_value (int, optional): Minimum value (inclusive). Defaults to 0.
    max_value (int, optional): Maximum value (inclusive). Defaults to 1000000.

Returns:
    str: JSON string containing the random number result

Application Scenarios:
1. Lottery systems
2. Game random numbers
3. Random ID generation
4. Test data generation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_valueNo
min_valueNo
saltNo

Implementation Reference

  • main.py:45-66 (handler)
    The @mcp.tool()-decorated handler function that defines the tool interface, schema via type hints and docstring, registers the tool, and delegates to the core helper implementation.
    @mcp.tool()
    async def generate_basic_random(salt: str = "", min_value: int = 0, max_value: int = 1000000) -> str:
        """Basic Random Number Generator
        
        Generate a random integer within the specified range
        
        Args:
            salt (str, optional): Random number salt value for increased randomness. Defaults to "".
            min_value (int, optional): Minimum value (inclusive). Defaults to 0.
            max_value (int, optional): Maximum value (inclusive). Defaults to 1000000.
        
        Returns:
            str: JSON string containing the random number result
        
        Application Scenarios:
        1. Lottery systems
        2. Game random numbers
        3. Random ID generation
        4. Test data generation
        """
        return await basic_random_generator(min_value=min_value, max_value=max_value, salt=salt)
  • Core helper function containing the exact random number generation logic: fetches blockchain entropy via get_random_str(), derives deterministic seed, seeds numpy RNG, generates value in range, returns structured result.
    async def basic_random_generator(min_value: int = 0, max_value: int = 1000000, salt: str="") -> dict:
        """Basic random number generator"""
        print(f"\nStarting to generate random number, parameters: salt={salt}, min={min_value}, max={max_value}")
        try:
            random_num = await get_random_str()
            if not random_num:
                print("Failed to get random number")
                return {"error": "Failed to get random number"}
                
            request_id = generate_request_id(random_num)
            print(f"Generated request ID: {request_id}")
            
            seed = _derive_seed(request_id, salt)
            print(f"Derived seed: {seed}")
            
            np.random.seed(seed)
            random_value = int(np.random.randint(min_value, max_value + 1))
            print(f"Generated random value: {random_value}")
                
            result = {
                "requestId": request_id,
                "randomValue": random_value
            }
            print(f"Final result: {result}")
            return result
        except Exception as e:
            print(f"Failed to generate random number: {str(e)}")
            return {"error": f"Failed to generate random number: {str(e)}"}
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that the tool generates random integers within inclusive bounds and returns JSON strings, but doesn't mention randomness quality, performance characteristics, or potential limitations. It adds basic behavioral context but could be more comprehensive for a tool with no annotation coverage.

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 well-structured with clear sections (Args, Returns, Application Scenarios) and front-loads the core purpose. While efficient, the 'Application Scenarios' section could be more concise by grouping similar use cases or using bullet points more effectively.

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 3-parameter tool with no annotations and no output schema, the description provides adequate coverage of inputs and basic behavior but lacks details about the JSON return format structure, error conditions, or performance considerations. It's minimally viable but has clear gaps in completeness.

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 - and it does by explaining all 3 parameters: salt ('for increased randomness'), min_value ('Minimum value (inclusive)'), and max_value ('Maximum value (inclusive)'). It provides meaningful semantics beyond the bare schema, though it could elaborate on how salt affects randomness.

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 ('within the specified range'), distinguishing it from sibling tools like generate_random_array or generate_random_weighted. The title 'Basic Random Number Generator' reinforces this purpose without being tautological.

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

Usage Guidelines4/5

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

The 'Application Scenarios' section provides clear context for when to use this tool (lottery systems, game random numbers, etc.), but it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools. This gives good guidance but lacks exclusion criteria.

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/suxiongye/random-web3-mcp'

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