Dice Rolling MCP Serverのロゴ

Dice Rolling MCP Server

コミュニティ
jimmcq

A TypeScript-based Model Context Protocol (MCP) server providing comprehensive dice rolling capabilities with advanced gaming mechanics

公開者jimmcq
リポジトリdice-rolling-mcp
言語TypeScript
フォーク
5
スター
8
利用可能なツール
0
通信方式stdio
カテゴリ
リンク
  • ツールをAIワークフローに接続

    Dice Rolling MCP Serverは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 利用可能なツール(0個)

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースプロジェクトの注目度

    リンク先のリポジトリには8件のスターと5件のフォークがあります。

Dice Rolling MCP Server

A comprehensive TypeScript-based Model Context Protocol (MCP) server that provides advanced dice rolling capabilities for AI assistants. Perfect for tabletop gaming, RPGs, and any application requiring sophisticated random number generation with gaming mechanics.

The Problem: LLMs Can't Actually Roll Dice

When you ask an AI assistant to "roll dice," they don't actually roll anything. Large Language Models are deterministic systems that generate responses based on patterns in their training data. When asked to roll a d20, they might respond with something like "I rolled a 14" - but that number was generated through text prediction, not random number generation.

This creates several problems:

  • No True Randomness: Results aren't genuinely random and may follow predictable patterns
  • Gaming Integrity: Critical for tabletop RPGs where fair dice rolls affect gameplay
  • Simulation Accuracy: Statistical simulations require proper random number generation
  • Reproducibility Issues: Same prompts might yield suspiciously similar "random" results

The Solution: Real Dice for AI

This MCP server acts as a bridge between AI assistants and actual random number generation. Think of it as giving your AI assistant a real set of dice instead of asking them to imagine rolling.

How it works:

  • AI assistant receives dice notation (e.g., "3d6+2")
  • MCP server parses the request and generates cryptographically secure random numbers
  • Real dice mechanics are applied (advantage, exploding dice, rerolls, etc.)
  • Genuine random results are returned to the AI

The result: AI assistants can now provide truly random dice rolls with mathematical integrity, making them suitable for actual gaming, simulations, and any application requiring authentic randomness.

Features

Standard Dice Notation

  • Basic rolls: 1d20, 3d6, 2d10
  • Modifiers: 1d20+5, 2d6-3
  • Multiple dice types: 1d20+2d6+3
  • Percentile dice: 1d% (d100)
  • Fudge dice: 4dF (Fate/Fudge system)

Advanced Mechanics

  • Advantage/Disadvantage: 2d20kh1 (keep highest), 2d20kl1 (keep lowest)
  • Drop mechanics: 4d6dl1 (drop lowest), 4d6dh1 (drop highest)
  • Exploding dice: 3d6! (reroll and add on maximum)
  • Reroll mechanics: 4d6r1 (reroll 1s)
  • Success counting: 5d10>7 (count successes ≥7)

MCP Tools

search

Discovers available dice rolling operations and documentation. Required for ChatGPT Connector compatibility.

Parameters:

  • query (required): Search query to find relevant dice rolling information

Returns:

  • content: JSON with search results containing id, title, and url fields
  • structuredContent: Machine-readable search results with relevance scoring

fetch

Retrieves detailed content for a specific dice rolling topic by ID.

Parameters:

  • id (required): Topic ID from search results

Returns:

  • content: JSON document with full content
  • structuredContent: Metadata and structured document information

dice_roll

Executes dice rolls using standard notation with optional labeling and verbose output.

Parameters:

  • notation (required): Dice notation string (e.g., "3d6+2")
  • label (optional): Descriptive label for the roll
  • verbose (optional): Show detailed breakdown of individual dice

Returns:

  • content: Human-readable text with roll results and emojis
  • structuredContent: Complete roll data including:
    • notation: Original dice notation
    • total: Final result
    • rolls: Individual die results with metadata (dropped, exploded, etc.)
    • breakdown: Mathematical breakdown string
    • critical: Critical success/fail detection for d20 rolls
    • modifier: Applied modifiers
    • timestamp: ISO timestamp of the roll

dice_validate

Validates dice notation without executing the roll, providing detailed breakdown of what the notation means.

Parameters:

  • notation (required): Dice notation string to validate

Returns:

  • content: Human-readable validation result
  • structuredContent: Structured validation data including:
    • valid: Boolean validation status
    • expression: Parsed dice expression (if valid)
    • breakdown: Structured breakdown of dice and modifiers
    • error: Error message (if invalid)

Structured Content Support

All tools return both human-readable content and machine-readable structuredContent following the OpenAI Apps SDK specification. This enables:

  • Programmatic access to roll results and validation data
  • Component templates for rich UI rendering (future enhancement)
  • Integration with AI workflows requiring structured data
  • Advanced features like roll history, statistics, and visualizations

The structured content includes complete metadata about each operation, making it suitable for building advanced applications on top of the dice rolling capabilities.

Remote MCP Integration (Streamable HTTP)

This MCP server supports Streamable HTTP transport for remote connections and implements the OpenAI MCP specification, including the required search tool for operation discovery.

Compatible With:

  • Claude Remote MCP Connectors (and Claude Desktop)
  • ChatGPT Connectors (currently only in Developer Mode)
  • Any MCP client supporting Streamable HTTP transport

Connection Endpoints:

  • Local Development: http://localhost:3000/mcp
  • Production: https://dice-rolling-mcp.vercel.app/mcp

The search and fetch tools enable both Claude and ChatGPT to discover available dice rolling operations automatically.

Local MCP Integration (STDIO)

For local Claude Desktop integration, configure your claude_desktop_config.json:

json
{
  "mcpServers": {
    "dice-rolling-remote": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/client-stdio", 
        "connect", 
        "https://dice-rolling-mcp.vercel.app/mcp"
      ]
    }
  }
}

Local Installation

bash
git clone https://github.com/jimmcq/dice-rolling-mcp
cd dice-rolling-mcp
npm install
npm run build

Usage

With Claude Desktop

Add to your claude_desktop_config.json:

json
{
  "mcpServers": {
    "dice-roller": {
      "command": "node",
      "args": ["path/to/dice-rolling-mcp/dist/index.js"]
    }
  }
}

Platform-specific examples:

Windows (WSL):

json
{
  "mcpServers": {
    "dice-roller": {
      "command": "wsl",
      "args": ["node", "/path/to/dice-rolling-mcp/dist/index.js"]
    }
  }
}

macOS/Linux:

json
{
  "mcpServers": {
    "dice-roller": {
      "command": "node",
      "args": ["/path/to/dice-rolling-mcp/dist/index.js"]
    }
  }
}

Standalone Server

bash
npm run start

Examples

Basic Rolling

Human: Roll 3d6+2 for damage
Assistant: You rolled 3d6+2 for damage:
🎲 Total: 13
📊 Breakdown: 3d6:[4,2,5] + 2

Advantage System

Human: Roll 2d20kh1+5 for attack with advantage
Assistant: You rolled 2d20kh1+5 for attack with advantage:
🎲 Total: 23
📊 Breakdown: 2d20:[12,18] keep highest + 5

Validation

Human: Is "4d6kh3+2d8+5" valid dice notation?
Assistant: ✅ Valid dice notation: 4d6kh3+2d8+5

Breakdown:
• 4d6 (keep highest 3)
• 2d8
• Modifier: +5

Discovery (Remote MCP Integration)

Human: What dice operations are available?
Assistant: [Calls search tool with query "dice"]
🎲 Found dice rolling operations:
- Basic Dice Notation: Learn standard XdY format
- D&D Advantage and Disadvantage: 2d20kh1 mechanics
- Combat Roll Examples: Attack, damage, spells
- Ability Score Generation: 4d6kh3 for character stats

Architecture

Core Components

  • Parser (src/parser/): Tokenizes and parses dice notation using regex-based parsing
  • Roller (src/roller/): Executes dice expressions with cryptographically secure random number generation
  • MCP Server (src/index.ts): Implements the Model Context Protocol for AI assistant integration
  • Type System (src/types.ts): Comprehensive TypeScript definitions for all dice mechanics

Key Design Decisions

  • Security: Uses Node.js crypto.randomInt() for cryptographically secure randomness
  • Extensibility: Modular architecture supports easy addition of new dice mechanics
  • Compatibility: ES2022 target with fallbacks for broader Node.js version support
  • Type Safety: Full TypeScript implementation with strict type checking

Testing

bash
npm test

The test suite covers:

  • Dice notation parsing for all supported mechanics
  • Roll execution with mocked random number generation
  • Edge cases and error handling
  • MCP protocol compliance

Development

Project Structure

dice-rolling-mcp/
├── src/
│   ├── index.ts              # MCP server implementation
│   ├── parser/               # Dice notation parser
│   ├── roller/               # Dice rolling engine
│   ├── statistics/           # Statistical analysis tools
│   └── types.ts              # TypeScript definitions
├── __tests__/                # Test suite
├── dist/                     # Compiled JavaScript
└── examples/                 # Usage examples

Adding New Mechanics

  1. Extend the DiceTerm interface in types.ts
  2. Update the parser regex in dice-notation-parser.ts
  3. Implement the mechanic in dice-roller.ts
  4. Add comprehensive tests

Configuration

The server supports various configuration options through the DiceRollerConfig interface:

  • Maximum dice count per roll
  • Maximum die size
  • Random number source selection
  • History size limits

Technical Specifications

  • Language: TypeScript 5.8+
  • Runtime: Node.js 18+ (tested with v24.0.2)
  • Protocol: MCP (Model Context Protocol) 2024-11-05
  • OpenAI Compatibility: Implements OpenAI MCP specification with required search tool
  • Transport Support: STDIO (local Claude Desktop) + Streamable HTTP (remote connections)
  • Dependencies: Minimal (zod, @modelcontextprotocol/sdk, @vercel/mcp-adapter)
  • Module System: ES Modules
  • Test Framework: Jest with ts-jest

Security Considerations

  • Input validation prevents malicious dice expressions
  • Resource limits prevent DoS through extremely large rolls
  • Cryptographically secure random number generation
  • No external network dependencies

Links

Author

Jim McQuillan

License

ISC

Contributing

Contributions welcome! Please ensure:

  • All tests pass (npm test)
  • Code follows existing patterns and conventions
  • New features include appropriate test coverage
  • TypeScript strict mode compliance

インストール

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "jimmcq-dice-rolling_mcp": {
      "command": "",
      "args": []
    }
  }
}

Dice Rolling MCP ServerのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度Dice Rolling MCP Serverに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」→「詳細設定」→「Model Context Protocol」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「Model Context Protocol」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

Dice Rolling MCP Serverをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. Dice Rolling MCP ServerのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタのステータスが「準備完了」のままか確認するには、画面を更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "jimmcq-dice-rolling_mcp": {
      "command": "npx",
      "args": [
        "-y",
        "dice-rolling-mcp"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてDice Rolling MCP ServerのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. Dice Rolling MCP ServerのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
Dice Rolling MCP Serverを使ってこのタスクを手伝ってもらえますか?
Dice Rolling MCP Server
はい、読みました。
Dice Rolling MCP Serverで調べた結果をお伝えします。

よくある質問

Dice Rolling MCP Server MCPサーバーは何に使いますか?

Dice Rolling MCP Serverは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでは、複数のAIモデルでDice Rolling MCP Server MCPを利用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでDice Rolling MCP Serverを利用できます。

TypingMindでDice Rolling MCP Server MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けのトップクラスのフロントエンドです。Dice Rolling MCP Serverを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

Dice Rolling MCP Server MCPをTypingMindに接続するにはどうすればよいですか?

Dice Rolling MCP ServerはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでDice Rolling MCP Server MCPのどのようなツールを利用できますか?

Dice Rolling MCP ServerはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

Dice Rolling MCP Server MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。Dice Rolling MCP Serverで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇