Skip to main content
Glama
lalrow

AI Makerspace MCP Demo Server

by lalrow

roll_dice

Generate random dice rolls using standard dice notation for games, simulations, or decision-making scenarios.

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:19-23 (handler)
    The primary handler for the 'roll_dice' MCP tool. Registered via @mcp.tool() decorator. It instantiates DiceRoller with inputs and returns its string representation containing the 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)
  • The __str__ method of DiceRoller class, which generates the formatted output string for single or multiple rolls by calling roll_dice or roll_multiple.
    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)
  • Core helper method in DiceRoller that parses dice notation (e.g., 2d20k1), rolls the dice using random.randint, sorts descending, 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
  • Helper method to perform multiple rolls when num_rolls > 1, aggregating results with totals.
    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
  • server.py:19-19 (registration)
    The @mcp.tool() decorator registers the roll_dice function as an MCP tool.
    @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/5.0
Behavior1/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 fails to mention the format of accepted notation, whether the roll is random, any constraints, error behavior, or the return value. This is a significant transparency gap.

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 very short and front-loaded, but it is under-specified. Every sentence is technically earned but the content is insufficient. It is concise at the expense of usefulness.

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?

Despite being a simple tool, the description is incomplete for an agent to use it correctly. It does not explain the expected notation syntax or the number of rolls, and while an output schema exists, the description does not help connect inputs to outputs. The description needs more detail to be functionally complete.

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

Parameters1/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 for parameter meaning. It only vaguely references 'notation' and completely ignores the 'num_rolls' parameter. The description provides essentially no semantic information beyond the parameter names.

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 is essentially a restatement of the tool name ('roll dice') with a vague reference to 'given notation'. It communicates the basic action but adds no detail about what notation is or how it differs from other tools. It's minimally clear but not strongly 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?

There is no guidance on when to use this tool versus alternatives, nor any context about suitable scenarios. The description simply states the action without implying any usage conditions or exclusions.

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