random_number
Generate a random number within a specified range for testing, sampling, or randomization needs in SEO workflows.
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
| Name | Required | Description | Default |
|---|---|---|---|
| min_value | No | ||
| max_value | No |
Implementation Reference
- mcp_ahrefs/tools/example_tools.py:40-58 (handler)The main tool handler function that generates a random integer between min_value and max_value, returning a dictionary with the number, range string, and timestamp. Includes input validation.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() }
- mcp_ahrefs/tools/example_tools.py:178-183 (registration)List of regular example tools including the random_number handler, which gets imported and looped over for registration in mcp_ahrefs/server/app.py.example_tools = [ echo_tool, get_time, random_number, calculate_fibonacci ]
- mcp_ahrefs/server/app.py:98-112 (registration)Registration loop that applies SAAGA decorators (exception_handler and tool_logger) to each tool in example_tools (including random_number) and registers them to the MCP server using 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}")