# Stop manual dice rolling: Giving LLMs a proper tabletop math engine via MCP

> Source: <https://dev.to/renato_marinho/stop-manual-dice-rolling-giving-llms-a-proper-tabletop-math-engine-via-mcp-32i2>
> Published: 2026-08-26 07:15:00+00:00

If you've ever tried to run a Dungeons & Dragons session using just a standard LLM window, you know exactly where it falls apart.

You ask for a roll. The model simulates it. It feels okay until you realize the probabilistic math isn't quite hitting the mark, or worse, it forgets the nuances of advantage/disadvantage rules. Then comes the heavy lifting—calculating damage while factoring in resistances, vulnerabilities, and proficiency bonuses. This is where 'hallucinated randomness' becomes a thing. Most people think they can just prompt their way around this. They can't.

The issue isn't intelligence; it's delegation. You shouldn't be asking an LLM to perform arithmetic or logic checks that follow strict, deterministic rulebooks. You should be giving it a tool that does those calculations perfectly so the agent can focus on being the Dungeon Master.

I looked into how we bridge this gap using the Model Context Protocol (MCP). Instead of teaching an agent how to play D&D through massive system prompts (which eats tokens and invites errors), we provide specialized tools that act as the mechanical backbone of the game.

A common mistake when building AI agents for gaming is assuming a basic `random()`

function call is enough. In TTRPGs, complexity hides in mechanics like advantage and disadvantage.

The `simulate_roll_outcome`

tool handles this correctly by calculating results based on two d20 rolls—picking the highest value for advantage and the lowest for disadvantage. By offloading this specific calculation to a dedicated MCP server, we remove the cognitive load from the LLM. It doesn't have to remember which die goes where; it just asks for the outcome and receives a mathematically sound result.

It goes deeper than just the initial roll. Real combat involves layers of modifiers:

`resolve_ability_check`

).`calculate_damage`

).When these are exposed as individual tools within an MCP ecosystem, the interaction loop changes from "guessing" to "executing." The agent identifies the intent (e.g., "The Orc hits with a greataxe!"), selects the correct tool sequence, and applies pure logic to get the number.

There is one technical hurdle I noticed when working with intensive computational tools in restricted environments: resource exhaustion. Specifically, seeing `[get_listing] Isolate ran out of memory or was disposed mid-execution`

.

This error usually pops up when you try to push too much data through a single tool execution—like trying to process an entire campaign history or thousands of monster stats in one go. If you hit this, don't keep throwing more RAM at it mentally; reduce the data footprint per request or simplify your computation logic. High-performance automation requires keeping payloads lean.

You can find this specific suite of tabletop mechanics available here: [https://vinkius.com/ai-agent-connect/dnd-mechanics](https://vinkius.com/ai-agent-connect/dnd-mechanics)

The shift toward agents isn't about making models smarter; it's about making them better equipped. Whether you are building a sophisticated DM assistant or automating complex physics simulations elsewhere, treating specialized logic as an external service (via MCP) is always superior to embedding that logic in a prompt.

You stop fighting with text descriptions of rules and start interacting with verified outputs.

The difference between an LLM that *pretends* to know D&D and an LLM that *plays* D&D is simply having access to a reliable mathematical oracle.

*MCPs are the music of AI Agents. We built the catalog. Discover Vinkius MCP Catalog.*
