trpg-dice-mcp

trpg-dice-mcp

A cryptographically secure dice rolling server for TRPGs, supporting complex dice expressions, multiple rule system presets, and hidden rolls with encryption.

Category
Visit Server

README

TRPG 掷骰 MCP Server v2.0

密码学安全真随机的 TRPG 掷骰服务器,支持完整骰子表达式引擎、多系统规则预设、暗骰保密。

快速开始

配置 MCP 客户端

在你的 MCP 客户端配置中添加:

{
  "mcpServers": {
    "trpg-dice": {
      "command": "npx",
      "args": ["-y", "trpg-dice-mcp"]
    }
  }
}

Windows 客户端

部分 Windows 环境需要:

{
  "mcpServers": {
    "trpg-dice": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "trpg-dice-mcp"]
    }
  }
}

工具一览

工具 用途 示例
roll_dice 掷骰表达式求值 3d6+2, 4d6kh3, d%, (8d6)/2
roll_table 随机表抽取(范围/权重/等概率) 遭遇表、战利品表
roll_check 技能/属性检定 CoC 7e、D&D 5e、PbtA、GURPS
roll_pool 骰池检定 Shadowrun、WoD、Year Zero
roll_fate FATE 检定 4dF + 修正值
pick_random 随机抽取 先攻排序、抽牌
get_roll_history 查询历史 最近掷骰记录
reveal_hidden_roll 揭示暗骰 追溯查看之前暗骰的完整结果
opposed_check 双方对抗检定 技能对抗、先攻对抗

支持的骰子表达式

基本语法

表达式 含义
3d6 掷 3 颗 6 面骰
1d20+5 d20 + 修正 5
4d6kh3 4d6 取最高的 3 个(D&D 属性)
2d20kl1 2d20 取最低的 1 个(劣势)
3d6! 爆炸骰(出 6 追加一骰)
1d6r2 重骰直到结果 > 2
(8d6)/2 8d6 结果除以 2(向下取整)
floor(3d6/2) 同上,显式 floor

特殊骰

记号 含义
d% / d100 百分骰(1–100)
dF Fudge 骰(-1/0/+1)
d66 查表骰(11–66,36 个离散值)

修饰符

修饰符 含义
khN 保留最高的 N 个
klN 保留最低的 N 个
dhN 丢弃最高的 N 个
dlN 丢弃最低的 N 个
! 爆炸(出最大值追加一骰)
!! 复合爆炸(累计为单骰值)
!>N 阈值爆炸(出 ≥N 追加)
rN 递归重骰直到结果 > N

规则预设

预设 系统 骰子 判定
coc7 克苏鲁的呼唤 7 版 1d100 ≤ 技能
dnd5e D&D 5 版 1d20+mod ≥ DC
pbta Powered by the Apocalypse 2d6+mod 固定阈值
gurps GURPS 3d6 ≤ 技能
runequest RuneQuest 1d100 ≤ 技能
fate FATE 4dF+mod vs 难度

模型可通过 rules://presets/{name} 资源查阅详细判定规则。

安全性

  • 随机源:使用 node:crypto.randomInt(),密码学安全,无模偏差
  • 暗骰:hidden: true 参数使结果不进入 LLM 上下文,仅写入本地加密存储
  • 揭示控制:暗骰揭示默认启用,GM 可通过 reveal_hidden_roll 工具回溯查看暗骰结果

开发

npm install
npm run build
npm test

项目结构

src/
├── index.ts          # stdio 入口
├── server.ts         # MCP 工具注册
├── rng/              # 随机数核心(SecureRng / SeededRng)
├── dice/             # 表达式引擎(tokenizer/parser/eval/range/table)
├── rules/            # 规则预设 + degrees DSL
├── resources/        # MCP Resources(规则速查)
├── state/            # 历史记录 + 暗骰存储
├── tools/            # 9 个 MCP 工具
└── utils/            # 格式化 / i18n

许可

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured