这是一个使用 Model Context Protocol (MCP) 的服务器,可以自动购买同行乐透的彩票并检查中奖结果。
# 账户设置助手
npx @labforadvanced.study/lotto-mcp-server --setup
# 或者直接编码
echo "your_id,your_password" | base64
Claude Desktop 设置:
{
"mcpServers": {
"lotto": {
"command": "npx",
"args": ["@labforadvanced.study/lotto-mcp-server"],
"env": {
"LOTTO_CREDENTIALS": "your_base64_credentials"
}
}
}
}
关于 npm 的详细用法,请参阅 NPM_GUIDE.md。
无需额外安装或构建,可以直接使用发布的 Docker 镜像!
在终端简单地进行编码:
# macOS/Linux
echo "your_lotto_id,your_password" | base64
# Windows (PowerShell)
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("your_id,your_password"))
# 示例结果: bXlfbG90dG9faWQsbXlfcGFzc3dvcmQ=
在 claude_desktop_config.json 文件中添加以下配置:
{
"mcpServers": {
"lotto": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "LOTTO_CREDENTIALS=bXlfbG90dG9faWQsbXlfcGFzc3dvcmQ=",
"your-dockerhub-username/lotto-mcp-server:latest"
]
}
}
}
重启 Claude Desktop 即可开始使用!
给我买三张彩票
# 安装依赖
npm install
# 安装 Playwright 浏览器
npm run install-playwright
# 构建
npm run build
# 方法 1-A: 使用交互式工具
npm run encrypt-credentials
# 选择: 1 (简单模式)
# 方法 1-B: 使用简单脚本
npm run simple-encode
# 方法 1-C: 在终端直接
echo "your_id,your_password" | base64
示例输出:
{
"mcpServers": {
"lotto": {
"command": "node",
"args": ["path/to/lotto-mcp-server/dist/index.js"],
"env": {
"LOTTO_CREDENTIALS": "eW91cl9pZCx5b3VyX3Bhc3N3b3Jk"
}
}
}
}
npm run encrypt-credentials
# 选择: 2 (高级模式)
示例输出:
{
"mcpServers": {
"lotto": {
"command": "node",
"args": ["path/to/lotto-mcp-server/dist/index.js"],
"env": {
"LOTTO_ENCRYPTED_ID": "YWJjZGVmZ2hpams...",
"LOTTO_ENCRYPTED_PASSWORD": "bXlwYXNzd29yZA...",
"LOTTO_SECRET_KEY": "optional-custom-key"
}
}
}
}
claude_desktop_config.json 文件中"path/to/lotto-mcp-server/dist/index.js" 替换为实际路径npm run dev
npm start
此 MCP 服务器提供以下两个工具:
purchase_lotto - 购买彩票自动从同行乐透购买彩票。ID/密码会从设置中自动获取。
输入参数:
count (number): 要购买的彩票游戏数量 (1-5)示例输出:
{
"success": true,
"numbers": [
[1, 14, 21, 27, 30, 44],
[4, 5, 27, 29, 40, 44],
[9, 18, 19, 24, 38, 42]
],
"message": "成功购买了3个游戏"
}
check_lotto_winning - 检查中奖检查彩票号码的中奖情况。
输入参数:
numbers (array): 要检查的彩票号码数组 (例如: [[1,2,3,4,5,6], [7,8,9,10,11,12]])round (number, 可选): 要检查的期数 (默认值: 当前期数)示例输出:
{
"success": true,
"results": [
{
"numbers": [1, 2, 3, 4, 5, 6],
"rank": 5,
"matchedNumbers": [1, 2, 3]
},
{
"numbers": [7, 8, 9, 10, 11, 12],
"rank": 0,
"matchedNumbers": []
}
],
"message": "检查了第1143期的中奖结果"
}
完成设置后,在 Claude 中可以这样使用:
给我买三张彩票
检查这些彩票号码是否中奖: [[1,2,3,4,5,6], [7,8,9,10,11,12]]
echo "id,password" | base64 简单生成可以在终端直接生成简单模式:
# macOS/Linux
echo "your_id,your_password" | base64
# Windows (PowerShell)
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("your_id,your_password"))
| 方式 | 安全级别 | 便利性 | 使用场景 |
|---|---|---|---|
| 简单模式 | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 一般用户,个人电脑 |
| 高级模式 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | 敏感环境,公用电脑 |
可以在 src/lotto-service.ts 文件中修改以下选项:
this.lottoService = new BaseLottoService({
controller: chromium,
headless: true, // 更改为 false 则显示浏览器窗口
defaultViewport: {
width: 1280,
height: 720
},
logLevel: 2 // 日志级别 (0: ERROR, 1: WARN, 2: INFO, 3: DEBUG)
});
lotto-mcp-server/
├── src/
│ ├── index.ts # MCP 服务器主文件
│ ├── lotto-service.ts # 彩票服务类
│ ├── crypto-utils.ts # 加密/解密工具
│ └── encrypt-credentials.ts # 账户信息编码工具
├── scripts/
│ └── simple-encode.sh # 简单编码脚本
├── dist/ # 构建结果
├── package.json
├── tsconfig.json
└── README.md
# 重新安装 Playwright 浏览器
npx playwright install chromium
# 使用简单模式重新设置
npm run simple-encode
# 或者使用高级模式重新设置
npm run encrypt-credentials
MIT License
欢迎提交 bug 报告或功能建议,请通过 Issue 提交。
此工具不使用同行乐透的官方 API,而是通过网页抓取实现。使用过程中产生的所有责任由用户自行承担,对于因过度使用而导致的账户处罚或其他问题,我们概不负责。