flip_coin
Simulate coin flips for decision-making or probability testing. Specify how many times to flip (1-100) and get the results.
Instructions
Flip a coin one or more times.
Args: times: Number of times to flip (1-100)
Returns: Results of the coin flip(s)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| times | No |
Implementation Reference
- src/mcp_dice_roller/server.py:158-183 (handler)The flip_coin tool handler implemented with @mcp.tool() decorator.
def flip_coin(times: int = 1) -> dict: """ Flip a coin one or more times. Args: times: Number of times to flip (1-100) Returns: Results of the coin flip(s) """ if times < 1 or times > 100: return {"error": "Times must be between 1 and 100"} flips = [random.choice(["heads", "tails"]) for _ in range(times)] if times == 1: return {"result": flips[0]} heads_count = flips.count("heads") tails_count = flips.count("tails") return { "flips": flips, "count": {"heads": heads_count, "tails": tails_count}, "total": times, }