Skip to main content
Glama

random_number

Generate a random number within a defined range using customizable minimum and maximum values. Ideal for tasks requiring randomized data selection or testing scenarios.

Instructions

Generate a random number within a specified range.

Args: min_value: Minimum value (default: 1) max_value: Maximum value (default: 100) Returns: Dictionary containing the random number and range info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_valueNo
min_valueNo

Implementation Reference

  • The main handler function that implements the random_number tool logic, generating a random integer between min_value and max_value inclusive, with validation and metadata return.
    async def random_number(min_value: int = 1, max_value: int = 100) -> Dict[str, Any]: """Generate a random number within a specified range. Args: min_value: Minimum value (default: 1) max_value: Maximum value (default: 100) Returns: Dictionary containing the random number and range info """ if min_value > max_value: raise ValueError("min_value must be less than or equal to max_value") number = random.randint(min_value, max_value) return { "number": number, "range": f"{min_value}-{max_value}", "timestamp": time.time() }
  • Registration loop that applies SAAGA decorators (exception handling and logging) to each tool in example_tools list (including random_number) and registers them explicitly with mcp_server.tool(name=tool_name).
    for tool_func in example_tools: # Apply SAAGA decorator chain: exception_handler → tool_logger decorated_func = exception_handler(tool_logger(tool_func, config.__dict__)) # Extract metadata from the original function tool_name = tool_func.__name__ # Register the decorated function directly with MCP # This preserves the function signature for parameter introspection mcp_server.tool( name=tool_name )(decorated_func) unified_logger.info(f"Registered tool: {tool_name}")
  • The list of regular example tools that includes the random_number handler function, which is imported into server/app.py and registered via the loop.
    example_tools = [ echo_tool, get_time, random_number, calculate_fibonacci ]
  • Import statement that brings in the example_tools list containing random_number for subsequent registration.
    from mcp_ahrefs.tools.example_tools import example_tools, parallel_example_tools

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/SAGAAIDEV/mcp-ahrefs'

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