Skip to main content
Glama
mwalker-tmd

Tavily Search MCP Server

by mwalker-tmd

roll_dice

Generate random dice rolls using standard notation to simulate probability outcomes for games, simulations, or decision-making processes.

Instructions

Roll the dice with the given notation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notationYes
num_rollsNo

Implementation Reference

  • server.py:18-23 (handler)
    The MCP tool handler for 'roll_dice', registered via @mcp.tool(). It creates a DiceRoller instance with the provided notation and number of rolls, then returns its string representation which contains the formatted roll results.
    @mcp.tool()
    def roll_dice(notation: str, num_rolls: int = 1) -> str:
        """Roll the dice with the given notation"""
        roller = DiceRoller(notation, num_rolls)
        return str(roller)
  • Helper method in DiceRoller class that parses the dice notation (supporting 'num_dice d sides k keep'), rolls the dice randomly, sorts descending, selects the highest 'keep' rolls, and returns all rolls and kept rolls.
    def roll_dice(self):
        match = self.dice_pattern.match(self.notation)
        if not match:
            raise ValueError("Invalid dice notation")
    
        num_dice = int(match.group(1))
        dice_sides = int(match.group(2))
        keep = int(match.group(4)) if match.group(4) else num_dice
    
        rolls = [random.randint(1, dice_sides) for _ in range(num_dice)]
        rolls.sort(reverse=True)
        kept_rolls = rolls[:keep]
    
        return rolls, kept_rolls
  • The __str__ method of DiceRoller, invoked by the handler, which calls roll_dice() (or roll_multiple()) to perform rolling and formats the results into the tool's output string, handling single or multiple rolls.
    def __str__(self):
        if self.num_rolls == 1:
            rolls, kept_rolls = self.roll_dice()
            return f"ROLLS: {', '.join(map(str, rolls))} -> RETURNS: {sum(kept_rolls)}"
        else:
            results = self.roll_multiple()
            result_strs = []
            for i, result in enumerate(results, 1):
                result_strs.append(f"Roll {i}: ROLLS: {', '.join(map(str, result['rolls']))} -> RETURNS: {result['total']}")
            return "\n".join(result_strs)
  • DiceRoller class initialization, storing notation and num_rolls, and compiling regex for parsing dice notation.
    class DiceRoller:
        def __init__(self, notation, num_rolls=1):
            self.notation = notation
            self.num_rolls = num_rolls
            self.dice_pattern = re.compile(r"(\d+)d(\d+)(k(\d+))?")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Roll') but doesn't explain key behaviors: whether this is a deterministic or random process, what the output format might be (e.g., individual rolls, totals, or details), or any constraints like rate limits. For a tool with no annotation coverage, this leaves significant gaps in understanding how it operates.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point without unnecessary words. It's front-loaded with the core action ('Roll the dice'), making it easy to scan. However, its brevity contributes to underspecification rather than optimal clarity, as it lacks details needed for full understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (involving dice notation and multiple rolls), no annotations, no output schema, and low schema description coverage, the description is incomplete. It doesn't explain what the tool returns (e.g., roll results), how errors are handled, or the semantics of parameters. For a tool that likely produces varied outputs, this leaves the agent with insufficient context to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/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 for undocumented parameters. It mentions 'notation' but doesn't define what that entails (e.g., standard dice notation like '3d10+2'). It doesn't address 'num_rolls' at all, leaving its purpose unclear. With two parameters and no schema descriptions, the description adds minimal semantic value beyond hinting at one parameter's role.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the action ('Roll') and the resource ('dice'), but it's vague about what 'with the given notation' means. It doesn't specify what the dice notation entails (e.g., '2d6' for two six-sided dice) or how it differs from potential siblings like 'web_search' or 'YOUR_TOOL_NAME', which are unrelated. This provides a basic purpose but lacks specificity and differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It doesn't mention any context for rolling dice (e.g., for games, simulations, or random generation) or exclusions (e.g., not for mathematical calculations). With sibling tools like 'web_search' that serve different purposes, this lack of comparative guidance leaves the agent to infer usage based on tool names alone.

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

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/mwalker-tmd/MCP-Session-Code'

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