MCP Lottery Demo
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Lottery Demo roll a 20-sided die 3 times for our D&D game"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP 抽签工具演示
这是一个完整的 MCP (Model Context Protocol) 插件示例,实现了抽签、投骰子、抛硬币等随机功能。
功能特性
🎲 抽签工具:从选项列表中随机抽取结果
🎯 投骰子:支持自定义面数和数量
🪙 抛硬币:简单的正面/反面随机选择
Related MCP server: mcp-randoom
安装和运行
安装依赖:
npm install启动 MCP 服务器:
方式一:标准输入输出模式(推荐用于 AI 客户端集成)
npm start方式二:HTTP 服务器模式(支持 Web 界面和网络访问)
npm run start:http启动后访问:
🌐 Web 界面:http://localhost:3000
📡 MCP 端点:http://localhost:3000/mcp
❤️ 健康检查:http://localhost:3000/health
工具说明
1. draw_lottery - 抽签工具
从给定的选项列表中随机抽取一个或多个结果。
参数:
options(必需): 抽签选项列表count(可选): 抽取数量,默认为1allow_duplicate(可选): 是否允许重复抽取,默认为false
示例:
{
"name": "draw_lottery",
"arguments": {
"options": ["苹果", "香蕉", "橙子", "葡萄"],
"count": 2,
"allow_duplicate": false
}
}2. roll_dice - 投骰子
投掷骰子,支持自定义面数和数量。
参数:
sides(可选): 骰子面数,默认为6count(可选): 骰子数量,默认为1
示例:
{
"name": "roll_dice",
"arguments": {
"sides": 20,
"count": 3
}
}3. flip_coin - 抛硬币
抛硬币,返回正面或反面。
参数:
count(可选): 抛硬币次数,默认为1
示例:
{
"name": "flip_coin",
"arguments": {
"count": 5
}
}演示 Prompt
以下是一些可以触发这些工具的示例 prompt:
基础抽签
帮我从这些水果中随机选一个:苹果、香蕉、橙子、葡萄、草莓多人抽签
我们5个人要分这些奖品:一等奖、二等奖、三等奖、四等奖、五等奖。请帮我们随机分配,每个人一个奖品。投骰子游戏
我想玩一个20面骰子的游戏,投3次,看看结果如何抛硬币决定
帮我抛5次硬币,看看正反面各出现多少次复杂抽签场景
我们班有30个同学,要选出5个代表参加活动。请帮我随机选择,不能重复。项目结构
mcp-lottery-demo/
├── package.json # 项目配置和依赖
├── README.md # 项目说明文档
├── demo-prompts.md # 演示 prompt 集合
├── test-client.js # 标准输入输出测试客户端
├── test-http-client.js # HTTP 测试客户端
├── demo.js # 演示脚本
└── src/
├── server.js # 标准输入输出 MCP 服务器
└── server-http.js # HTTP MCP 服务器技术实现
使用
@modelcontextprotocol/sdk构建 MCP 服务器两种传输模式:
标准输入输出传输协议(用于 AI 客户端集成)
HTTP/SSE 传输协议(支持 Web 界面和网络访问)
实现了完整的工具注册和调用机制
包含错误处理和参数验证
提供 Web 界面和 RESTful API
扩展建议
你可以基于这个示例扩展更多功能:
添加更多随机工具:如随机数生成器、随机颜色选择等
持久化存储:保存抽签历史记录
用户偏好:记住用户的常用选项
统计分析:提供抽签结果的统计分析
可视化:生成图表展示结果分布
许可证
MIT License
Available Tools
3 toolsdraw_lotteryB
从给定的选项列表中随机抽取一个或多个结果
Inputs: options (required), allow_duplicate, count.
flip_coinB
抛硬币,返回正面或反面
Inputs: count.
roll_diceC
投掷骰子,支持自定义面数和数量
Inputs: count, sides.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: draw_lottery selects from a list of options, flip_coin returns heads or tails, and roll_dice handles dice with customizable faces and counts. There is no overlap or ambiguity between these random selection mechanisms.
All tools follow a consistent verb_noun pattern (draw_lottery, flip_coin, roll_dice) with clear, descriptive names that accurately reflect their functions. The naming is uniform and predictable throughout the set.
With 3 tools, the server is well-scoped for a lottery/gambling demo, covering common random selection scenarios (lottery draws, coin flips, dice rolls). Each tool earns its place without feeling excessive or insufficient for the domain.
The tool set provides complete coverage for basic random selection operations in a gambling context: drawing from options, binary coin flips, and customizable dice rolls. There are no obvious gaps for the stated demo purpose, and agents can handle typical use cases without dead ends.
Maintenance
Related MCP Connectors
Fair, reproducible randomness for agents: dice, coins, integers, list picks, shuffles, with seeds.
Fair, reproducible randomness for agents: dice, coins, integers, list picks, shuffles, with seeds.
Fair, reproducible randomness for agents: dice, coins, integers, list picks, shuffles, with seeds.
Fair random picks with the wheel in your chat: pick names, split teams, run certified draws.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides comprehensive dice rolling, coin flipping, and tabletop RPG mechanics for AI assistants like Claude. It enables real-time tabletop gaming through features such as standard NdM notation, advantage/disadvantage rolls, and D\&D character stat generation.1-
- AlicenseNot gradedqualityDmaintenanceProvides true random generation tools for AI agents, including coin flip, dice roller, random numbers, and wheel of fortune, enabling decisions and TTRPG sessions.7 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables coin flips and dice rolls with standard notation and D&D mechanics like advantage/disadvantage and ability score generation.Apache 2.0

NameWheel MCP serverofficial
AlicenseAqualityBmaintenanceEnables fair random picks, team splits and wheel spins inside chat assistants and other MCP clients, with results shown in chat. It also runs certified draws that seal the winner before the spin and publish a verifiable public proof page, so anyone can check the outcome.8MIT