Skip to main content
Glama

generate_random_seed

Generate high-entropy random seeds for encryption, key generation, or unique identifiers using blockchain hash as an entropy source. Supports custom seed length and optional salt for enhanced randomness.

Instructions

Random Seed Generator

Generate high-entropy random seed for encryption or other scenarios requiring high-quality random numbers.
Uses blockchain hash as entropy source to ensure randomness.

Args:
    seed_length (int): Length of seed to generate (in bytes)
    salt (str, optional): Random number salt value for increased randomness. Defaults to "".

Returns:
    str: JSON string containing random seed, formatted as:
    {
        "requestId": "Generated request ID",
        "randomSeed": "Random seed in hexadecimal format",
        "entropy": Estimated entropy value
    }

Application Scenarios:
1. Key generation (encryption keys, signature seeds)
2. Security tokens (session identifiers, authentication tokens)
3. Random number initialization (PRNG seeds, simulation initial states)
4. Unique identifier generation (UUID seeds, random identifiers)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
saltNo
seed_lengthYes

Implementation Reference

  • main.py:213-238 (handler)
    MCP tool handler for generate_random_seed, including input schema via type hints and docstring, registration via @mcp.tool(), and execution logic delegating to utility function.
    @mcp.tool()
    async def generate_random_seed(seed_length: int, salt: str = "") -> str:
        """Random Seed Generator
    
        Generate high-entropy random seed for encryption or other scenarios requiring high-quality random numbers.
        Uses blockchain hash as entropy source to ensure randomness.
    
        Args:
            seed_length (int): Length of seed to generate (in bytes)
            salt (str, optional): Random number salt value for increased randomness. Defaults to "".
    
        Returns:
            str: JSON string containing random seed, formatted as:
            {
                "requestId": "Generated request ID",
                "randomSeed": "Random seed in hexadecimal format",
                "entropy": Estimated entropy value
            }
    
        Application Scenarios:
        1. Key generation (encryption keys, signature seeds)
        2. Security tokens (session identifiers, authentication tokens)
        3. Random number initialization (PRNG seeds, simulation initial states)
        4. Unique identifier generation (UUID seeds, random identifiers)
        """
        return await random_seed_generator(seed_length, salt)
  • Core helper function implementing the random seed generation logic using multi-chain block hashes for high entropy, SHA-256 extension, and entropy estimation.
    async def random_seed_generator(seed_length: int, salt: str="") -> Dict:
        """
        Random seed generator
        
        Generate high-entropy random seed
        
        Args:
            seed_length: Length of seed in bytes
            salt: Optional salt value for additional randomness
            
        Returns:
            Dict containing random seed and entropy estimation
        """
        random_num = await get_random_str()
        if not random_num:
            return {"error": "Failed to get random number"}
        request_id = generate_request_id(random_num)
        combined_source = f"{random_num}{request_id}{salt}"
        
        # Create initial hash using SHA-256
        initial_hash = hashlib.sha256(combined_source.encode()).digest()
        
        # Extend seed to required length
        seed_bytes = bytearray()
        while len(seed_bytes) < seed_length:
            # Use counter as additional entropy
            counter = len(seed_bytes).to_bytes(4, byteorder='little')
            next_hash = hashlib.sha256(initial_hash + counter).digest()
            seed_bytes.extend(next_hash)
        
        # Truncate to required length
        seed_bytes = seed_bytes[:seed_length]
        
        # Calculate approximate entropy
        entropy = _estimate_entropy(seed_bytes)
        
        result = {
            "requestId": request_id,
            "randomSeed": seed_bytes.hex(),
            "entropy": entropy
        }
        
        return result
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it explains the entropy source (blockchain hash), describes the return format in detail, and mentions the optional salt parameter with its default value. It doesn't cover potential limitations like rate limits or error conditions, but provides substantial operational context.

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 (purpose, args, returns, scenarios) and front-loaded with the core purpose. While comprehensive, some sentences in the scenarios section could be more concise, but overall it maintains good information density with minimal redundancy.

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

Completeness5/5

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

Given the complexity (security-focused random generation), lack of annotations, and absence of output schema, the description provides excellent completeness. It covers purpose, parameters, return format, use cases, and implementation details (entropy source), giving the agent everything needed to understand and invoke this tool correctly without structured metadata.

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 description adds significant meaning beyond the input schema, which has 0% description coverage. It explains what 'seed_length' represents (bytes), clarifies that 'salt' is optional with a default value and its purpose ('for increased randomness'), and provides context about how these parameters affect the generation process, fully compensating for the schema's lack of documentation.

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 tool's purpose with specific verb ('Generate') and resource ('high-entropy random seed'), and distinguishes it from siblings by specifying its unique use for encryption/security scenarios requiring high-quality randomness, unlike more general random generation tools in the sibling list.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance through the 'Application Scenarios' section, listing four specific use cases (key generation, security tokens, etc.), and implicitly distinguishes it from siblings by emphasizing high-quality randomness for security applications, which helps the agent select this over other random generation tools.

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