Skip to main content
Glama
bakshidwarak

Tavily Web Search MCP Server

by bakshidwarak

roll_dice

Simulate dice rolls using standard dice notation to generate random numbers for games, probability calculations, or decision-making scenarios.

Instructions

Roll the dice with the given notation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notationYes
num_rollsNo

Implementation Reference

  • server.py:18-22 (handler)
    MCP tool handler for 'roll_dice'. Registers the tool via @mcp.tool() decorator and implements the logic by instantiating DiceRoller and returning its string representation.
    @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)
  • DiceRoller class providing the core dice rolling functionality used by the roll_dice tool handler. Includes parsing of dice notation (e.g., 2d20k1), random roll generation, sorting, keeping highest rolls, multiple rolls support, and formatted output.
    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+))?")
    
        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
    
        def roll_multiple(self):
            """Roll the dice multiple times according to num_rolls"""
            results = []
            for _ in range(self.num_rolls):
                rolls, kept_rolls = self.roll_dice()
                results.append({
                    "rolls": rolls,
                    "kept": kept_rolls,
                    "total": sum(kept_rolls)
                })
            return results
    
        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)
  • server.py:18-18 (registration)
    Registration of the roll_dice tool using the @mcp.tool() decorator from FastMCP.
    @mcp.tool()

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.0
    • addedInput schema / title
      Added value: +"roll_diceArguments"
  2. First observed

TDQS

C2.3/5.0
Behavior1/5

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

No annotations are present, so the description must disclose behavioral traits. It only says 'Roll the dice,' which is a direct restatement of the tool name and adds no depth about random generation, validation, error handling, or return format. This is effectively a tautology with no added transparency.

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

Conciseness3/5

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

The description is a single concise sentence with no waste, which is positive. However, it is under-specified: it front-loads little useful information and does not structure any context for the parameters. It cannot be considered 'appropriately sized' because it omits essential detail.

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

Completeness1/5

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

For a tool with two parameters, no output schema, and no annotations, the description is severely inadequate. It does not explain dice notation, the meaning of num_rolls, or any behaviors/limitations. Even the sibling context (web_search) offers no help in situating this tool, making the description insufficient for reliable tool invocation.

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?

Schema description coverage is 0%, so the description must compensate. 'Given notation' loosely aligns with the 'notation' parameter but fails to define its format or semantics. The 'num_rolls' parameter is entirely absent from the description, leaving its purpose unexplained. Overall, minimal added meaning beyond the schema titles.

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

Purpose4/5

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

The description states a clear verb ('Roll') and resource ('dice'), indicating the tool's primary action. However, it does not specify what 'notation' means (e.g., standard dice notation like '2d6'), which leaves some ambiguity. It is distinct from the sibling web_search, but not explicitly differentiated.

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?

No guidance is provided on when to use this tool vs alternatives. The sibling list includes web_search, but the description gives no context for when dice rolling is appropriate or any exclusions. Users are left to infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools