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

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