Skip to main content
Glama
zazencodes

Random Number MCP

by zazencodes

secure_token_hex

Generate cryptographically secure random hexadecimal tokens for secure authentication, API keys, or session IDs. Specify the number of bytes to customize token length.

Instructions

Generate a secure random hex token.

Args: nbytes: Number of random bytes to generate (default 32)

Returns: Hex string containing 2*nbytes characters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nbytesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP handler function for 'secure_token_hex' tool, registered with @app.tool() decorator, delegates implementation to tools.secure_token_hex
    @app.tool()
    def secure_token_hex(nbytes: int = 32) -> str:
        """Generate a secure random hex token.
    
        Args:
            nbytes: Number of random bytes to generate (default 32)
    
        Returns:
            Hex string containing 2*nbytes characters
        """
        return tools.secure_token_hex(nbytes)
  • Core helper function implementing secure random hex token generation using Python's secrets module with input validation.
    def secure_token_hex(nbytes: int = 32) -> str:
        """Generate a secure random hex token.
    
        Args:
            nbytes: Number of random bytes to generate (default 32)
    
        Returns:
            Hex string containing 2*nbytes characters
    
        Raises:
            ValueError: If nbytes < 0
            TypeError: If nbytes is not an integer
        """
        validate_positive_int(nbytes, "nbytes")
        return secrets.token_hex(nbytes)
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. It discloses key behavioral traits: the tool generates secure random data, specifies the default parameter value (32 bytes), and describes the return format (hex string). However, it lacks details on security guarantees, randomness sources, or error handling.

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 sections for arguments and returns. Every sentence adds value with no redundancy, making it efficient and well-organized.

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 optional parameter) and the presence of an output schema (which covers return values), the description is largely complete. It explains the parameter and output adequately, though it could benefit from more context on security or randomness quality.

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 description coverage is 0%, so the description must compensate. It fully explains the single parameter 'nbytes' (number of random bytes to generate), provides the default value (32), and clarifies the output length (2*nbytes characters). This adds significant meaning beyond the bare schema.

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 secure random hex token') and distinguishes it from sibling tools like random_int or secure_random_int by specifying the output format (hex token). It provides a verb+resource combination that is 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 for generating secure hex tokens, but does not explicitly state when to use this tool versus alternatives like secure_random_int or other random siblings. No guidance on exclusions or specific contexts is provided.

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