Skip to main content
Glama
julie-berlin

Tavily Web Search MCP Server

by julie-berlin

roll_dice

Generate random dice rolls using standard notation like '2d6+3' to simulate probability-based outcomes for games, decisions, or calculations.

Instructions

Roll the dice with the given notation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notationYes
num_rollsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:20-24 (handler)
    The main handler function for the 'roll_dice' MCP tool. Registered via @mcp.tool(), it instantiates DiceRoller with the input parameters and returns its formatted string output which performs the actual dice rolls.
    @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 (e.g., '2d20k1'), generates random rolls, sorts them descending, keeps the highest 'k' 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 that executes the rolls (via roll_dice or roll_multiple) and formats the output string with roll details and totals, used by the tool handler.
    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:20-20 (registration)
    The @mcp.tool() decorator registers the roll_dice function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool rolls dice but doesn't disclose behavioral traits like whether it's deterministic, random, or has any side effects. It mentions 'given notation' but doesn't explain what that entails. More context on how the tool behaves is needed.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action. Every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's low complexity (simple dice rolling), no annotations, and an output schema exists (which likely explains return values), the description is somewhat complete but lacks details. It covers the basic purpose but misses parameter explanations and behavioral context, making it adequate but with gaps.

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. It mentions 'given notation' which hints at the 'notation' parameter, but doesn't explain what dice notation is (e.g., '2d6' for two six-sided dice). It doesn't address the 'num_rolls' parameter at all. The description adds minimal meaning beyond the bare schema.

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 'Roll the dice with the given notation' states the action (roll) and resource (dice), but is vague about what 'given notation' means. It doesn't distinguish from sibling tools (get_exchange_rate, web_search), which is fine as they're unrelated. The purpose is understandable but lacks specificity about dice notation formats.

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 on when to use this tool versus alternatives is provided. The description doesn't mention any context, prerequisites, or exclusions. Since sibling tools are unrelated (currency exchange and web search), this isn't critical, but there's no usage advice at all.

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/julie-berlin/pub-aie7-mcp-session'

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