Skip to main content
Glama
saidsurucu

d20-mcp

by saidsurucu

validate_syntax

Verify dice expression syntax before rolling. Perfect for user input validation and catching errors without dice rolls.

Instructions

Validate a dice expression's syntax without actually rolling any dice.

PURPOSE: Use this tool to check if a dice expression is syntactically correct and can be evaluated before actually rolling it. Perfect for validating user input, testing complex expressions, or checking syntax in application development. This is a read-only operation that doesn't generate random results.

WHEN TO USE:

  • User input validation: Check if user-provided expression is valid

  • Testing complex expressions: Verify syntax before committing to a roll

  • Application development: Validate dice notation in forms/configs

  • Error prevention: Catch syntax errors before attempting a roll

  • Teaching: Show users why an expression is invalid

  • API integration: Validate before passing to game systems

WHEN NOT TO USE:

  • If you want to actually roll dice (use roll, roll_detailed, or roll_batch)

  • If the expression is simple and you're confident in its syntax

  • When immediate rolling is acceptable even if it fails

VALIDATION SCOPE: This tool checks: ✓ Basic dice notation (NdN format) ✓ Arithmetic operators and precedence ✓ Keep/drop/reroll/explode operations ✓ Parentheses matching and nesting ✓ Valid operator combinations ✓ Number format and ranges

This tool does NOT check: ✗ Logical sense (e.g., "1d0" may pass but isn't useful) ✗ Performance implications (e.g., "99999d99999" is valid but slow) ✗ Statistical properties of the roll

COMMON EXAMPLES:

Valid Expressions:

  • "1d20+5" → ✓ Valid

  • "4d6kh3" → ✓ Valid

  • "2d20kh1+5" → ✓ Valid (advantage)

  • "(1d4+1)*2" → ✓ Valid (parentheses)

  • "3d6e6" → ✓ Valid (exploding)

Invalid Expressions:

  • "1d" → ✗ Invalid (missing die size)

  • "d20+" → ✗ Invalid (incomplete expression)

  • "1d20kh" → ✗ Invalid (missing keep count)

  • "roll 1d20" → ✗ Invalid (text instead of pure notation)

  • "1d20 +" → ✗ Invalid (trailing operator)

USE CASES:

Form Validation: Before saving a custom dice formula in a character sheet, validate it first.

Complex Expression Testing: Testing: "(2d6+3)*1d4kh1" before using in game Validate → If valid, then roll

User Input: User types: "3d8+5" Validate → Show ✓ or explain error → Then allow roll

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesDice expression to validate
Behavior5/5

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

Even without annotations, the description fully discloses behavior: it is read-only, produces no random results, and explicitly lists what it checks and does NOT check (e.g., logical sense like '1d0' passing, performance implications). This gives the agent a complete understanding of the tool's capabilities and limitations.

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 front-loaded with the purpose in the first sentence and uses clear section headings for organization. It is somewhat long for a tool with one parameter, but every section adds value through examples and use cases, so it earns its length. Slight deduction for verbosity.

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

Completeness5/5

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

The description is complete for a simple validation tool: it covers purpose, usage guidelines, validation scope, examples, and real-world use cases. Since there is no output schema, the description doesn't need to explain return values, but it fully compensates for the lack of annotations and provides all necessary context.

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

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema only says 'Dice expression to validate', but the description provides extensive parameter semantics through valid/invalid examples (e.g., '1d20+5' valid, '1d' invalid) and explains what constitutes valid syntax. This goes far beyond the schema's minimal description.

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

Purpose5/5

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

The description immediately states the tool validates dice expression syntax without rolling dice, which is specific and unambiguous. It clearly distinguishes this from sibling roll tools by emphasizing the non-rolling, read-only validation purpose.

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

Usage Guidelines5/5

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

The description provides explicit 'WHEN TO USE' and 'WHEN NOT TO USE' sections, naming alternatives like roll, roll_detailed, and roll_batch. It lists concrete use cases such as user input validation and form validation, making it easy to decide when to invoke this tool.

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/saidsurucu/d20-mcp'

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