mcd-saver-strategist README

The project's README from github.com/hujjun/mcd-saver-strategist. As one markdown file: README.md.

麦门省钱精算师 · mcd-saver-strategist

基于 麦当劳中国 MCP(McDonald's China MCP) 开发的省钱点餐 Skill / AI 智能体技能: 把「菜单 × 优惠券 × 叠加规则」的组合优化交给确定性算法, 让每一顿麦麦都点得明明白白、省得清清楚楚。 又名:麦门省钱精算师 / 麦当劳省钱点餐助手 / MCD Saver Strategist。

麦当劳程序员创意开发大赛参赛作品 · 非麦当劳官方产品。

CI Python 零依赖 测试


一句话介绍

用户说"我想吃巨无霸套餐,怎么最便宜",它拉取门店菜单和所有可用优惠券, 用算法穷举出总价最低的合规组合,并帮你下单。

示例:巨无霸 + 中薯条 + 可乐,直选 ¥47.00; 用「1+1 随心配」组合后 ¥21.90,省 ¥25.10(53%)。

它不止会算"最便宜",还能回答四个衍生问题:

问题 能力
这顿饭我想省钱 / 吃全 / 低卡 / 少排队 多目标优化:4 种点餐目标,同一约束给不同最优解
手里这堆券,哪张真便宜哪张是坑? 券体检:名义面额 vs 实际节省 vs 机会成本
差几块钱到下一档满减,加购划不划算? 凑单建议:最小代价补位,算出净变化(可能为负)
便宜和低卡不可兼得,边界在哪? 帕累托前沿:价格 × 热量的不可支配解集
一家人 / 一桌同事怎么点? 多人拼单:按份数计价、人均分摊,优惠只计一次(保守)

🎮 在线试算(无需登录):https://hujjun.github.io/mcd-saver-strategist/ —— 优化算法的前端完整复刻,选好想吃的、切换目标、拖动预算和热量上限,实时算出最优组合; 页面里还有券体检和帕累托前沿图,打开即玩。

🔎 静态示例:docs/demo.html · 🖼️ 原理图:images/how-it-works.png · 🎬 宣传动画:images/promo.mp4

在线试算页

原理图


它解决什么问题

麦当劳的优惠是典型的组合爆炸问题:

本 Skill 的核心洞察是:取数交给 MCP,算术交给代码,表达交给 Agent。

角色 职责
麦当劳 MCP 实时菜单、价格、优惠券、营养、门店、下单
scripts/optimizer.py 确定性组合优化,输出总价最低的 Top-N 方案
WorkBuddy Agent 理解需求、归一化数据、讲解方案、确认后下单

架构

flowchart TD
    U[用户: 想吃X, 预算Y, 热量Z] --> A[WorkBuddy Agent]
    A -->|now-time-info| M[麦当劳 MCP<br/>mcp.mcd.cn]
    A -->|nearby/delivery stores| M
    A -->|query-meals / meal-detail| M
    A -->|auto-bind + 3路券池| M
    A -->|list-nutrition-foods| M
    M --> N[归一化<br/>menu/coupons/request.json]
    N --> O[optimizer.py<br/>确定性组合优化]
    O --> P[Top-N 最优方案]
    P --> A
    A -->|calculate-price 核价| M
    A --> Q{用户确认?}
    Q -->|是| C[create-order]
    Q -->|否| P
    C --> R[支付链接]

一句话安装

git clone https://github.com/hujjun/mcd-saver-strategist.git && cp -r mcd-saver-strategist/skills/mcd-saver-strategist ~/.workbuddy/skills/

(Windows 为 %USERPROFILE%\.workbuddy\skills\;MCP Token 配置见下文「安装」。)


安装

1. 申请麦当劳 MCP Token

前往麦当劳 MCP 开放平台 https://open.mcd.cn/mcp ,手机号登录后在「控制台」激活并复制 Token。

2. 配置 MCP 连接

在 WorkBuddy 左侧边栏【专家·技能·连接器】→【连接器】→ 右上角【自定义连接器】→【配置 MCP】中, 填入 mcp-config.example.json 的内容, 并把 ${MCD_MCP_TOKEN} 替换为你的真实 Token(或用环境变量注入),保存后【启用】。

3. 安装本 Skill

把 skills/mcd-saver-strategist/ 整个目录复制到 WorkBuddy 的用户技能目录:

cp -r skills/mcd-saver-strategist ~/.workbuddy/skills/

(Windows 为 %USERPROFILE%\.workbuddy\skills\)

装好后在对话框里直接说「我想吃巨无霸套餐,怎么点最便宜」即可触发。


使用示例

示例 1 · 单人到店

用户:我想吃巨无霸 + 薯条 + 可乐,怎么最便宜?

精算师:拉菜单 + 四路券池 → 优化 → 「1+1 随心配 ¥12.9 覆盖巨无霸和中薯条,另外单点可乐 ¥9, 合计 ¥21.90,比直选省 ¥25.10」。

示例 2 · 预算硬约束

用户:30 块钱在麦当劳能吃到什么?

精算师:以 budget=30 求解,返回在预算内的最优搭配,并列出各方案到手价与热量。

示例 3 · 热量约束

用户:减脂期,想吃麦当劳,800 大卡以内还要便宜。

精算师:引入 list-nutrition-foods,以 max_calories=800 求解, 给出低卡又省钱的组合(如板烧鸡腿堡 + 麦咖啡 + 圆筒)。

示例 4 · 外送

用户:帮我在麦乐送点一份午餐,别超过 40。

精算师:delivery-query-addresses → delivery-query-stores → 后续流程同上, 下单前用 calculate-price 核价(含配送费)。

示例 5 · 券太多不会用

用户:我有 8 张券,帮我看看哪张值得用。

精算师:四路券池归一化 → audit_coupons() 逐张体检 → 「1+1 随心配值得用;这张'满 35 减 7'名义省 7 元,但用了它就吃不到 1+1,反而多花 18 元」。

示例 6 · 凑单

用户:还差多少能到满减?加个什么划算?

精算师:suggest_gap() 用子集和 DP 找最小代价补位 → 「还差 7 元,加个香芋派 7.5 元,多减 12 元,净省 4.5 元」。

示例 7 · 多人拼单

用户:我们 3 个人各要一份,一共多少钱?

精算师:party_size=3 求解 → 总价 + 人均,优惠只计一次(保守计价,不报假低价)。


命令行快速体验(无需 Token)

内置样例数据,可离线跑通完整优化流程:

cd skills/mcd-saver-strategist/scripts

# 看优化结果(默认到店自取场景)
python optimizer.py

# 同时输出结构化 JSON
python optimizer.py --json

# 一键看 7 个真实场景(含拼单 / 外送 / 券体检 / 凑单)
python demo.py

# 切换点餐目标: cheapest(默认) / balanced / lightest / fewest
python optimizer.py --objective lightest

# 多人拼单
python optimizer.py --party 3

# 券体检: 每张券的名义面额 vs 实际节省 vs 机会成本
python optimizer.py --audit

# 外送场景: 配送费计入总价, 且仅外送可用的券参与优化
python optimizer.py --mode delivery --fee 9

# 预算 / 热量硬约束
python optimizer.py --budget 25
python optimizer.py --max-calories 800

# 跑 46 项自测(改逻辑后必跑)
python selftest.py

# 性能基准: 菜品 10~160 款规模下的耗时
python bench.py

# 真实 MCP 连通自检(需 Token, 证明数据链路是真的)
export MCD_MCP_TOKEN=你的token
python mcp_probe.py --call now-time-info

# 前后端对拍: 页面试算器与 optimizer.py 是否一致(需 Node)
node parity_check.mjs

真实性对照表

项目 性质 说明
优化算法 ✅ 真实 optimizer.py 与在线试算页为同一套逻辑,且 CI 里有 17 项前后端对拍防漂移
「省 53%」结论 ✅ 真实 算法在示例数据上算出,非人工编排
券叠加规则 ✅ 真实 保守策略:stackable:false 与任何券互斥,保证方案价 ≤ 实付价
MCP 数据链路 ✅ 真实 mcp_probe.py 可现场验证:Token 握手 + 35 个工具清单 + 试调用
菜单价格 / 热量 🟡 示例快照 结构对齐 MCP 返回,数值为演示用,以门店实时返回为准
优惠券内容 🟡 示例快照 结构对齐 MCP 四路券池归一化结果,可用性以账号实时状态为准
下单能力 ✅ 真实 经 MCP 核价(calculate-price)→ 下单(create-order),本仓库页面不涉及下单

实测发现

开发过程中用真实 MCP 联调得到的观察(2026-10,个人账号实测):


目录结构

.
├── README.md                      # 本文件
├── CONTEST_DECLARATION.md         # 参赛声明(官方原文,未改动)
├── MCP_INTEGRATION.md             # MCP 集成说明:Tool 清单 / 调用流程 / 业务价值
├── mcp-config.example.json        # 脱敏 MCP 配置(仅环境变量占位符)
├── workbuddy.md                   # WorkBuddy 开发对话上下文
├── LICENSE                        # MIT
├── .github/workflows/ci.yml       # CI: 46 项自测 + 前后端对拍 + 性能基准
├── docs/
│   ├── index.html                 # 可交互在线试算(多目标 + 券体检 + 帕累托图)
│   ├── demo.html                  # 静态示例快照
│   └── preview.png                # 在线试算页整页截图
├── images/
│   ├── how-it-works.svg / .png    # 「省 53% 是怎么算出来的」原理图
│   └── promo.mp4                  # 宣传动画(AI 生成,仅作视觉物料)
└── skills/mcd-saver-strategist/   # ← Skill 本体
    ├── SKILL.md                   # 技能指令(Agent 加载)
    ├── scripts/
    │   ├── optimizer.py           # 确定性优惠组合优化器 v2(纯标准库)
    │   ├── selftest.py            # 46 项自测
    │   ├── demo.py                # 7 个真实场景一键演示
    │   ├── bench.py               # 性能基准(规模 × 耗时)
    │   ├── mcp_probe.py           # MCP 连通自检(握手 / 工具清单 / 试调用)
    │   ├── parity_check.mjs       # 前后端对拍(页面引擎 = optimizer.py)
    │   └── sample_data/           # 离线示例:菜单/券/请求
    └── references/
        ├── mcp-tools.md           # MCP Tool 清单与字段映射
        └── coupon-strategy.md     # 5 类券建模与省钱策略

目标用户


技术亮点


搜索关键词

🔍 想用哪些词能搜到本项目?(点开查看)

中文:麦当劳 · 麦门 · 麦当劳优惠券 · 麦当劳省钱 · 麦当劳点餐 · 麦乐送 / 外送 · 巨无霸 · 1+1 随心配 · 优惠券组合 / 叠加 · 满减 · 组合优化 · 省钱算法 · 麦当劳程序员创意开发大赛 · WorkBuddy 技能 · AI 智能体 · Agent Skill

English: McDonald's / McDonalds China / MCD · MCP (Model Context Protocol) · mcd-mcp · coupon optimizer · coupon combination · money saving · fast food deals · deterministic optimization · brute-force search · WorkBuddy skill · AI agent · agent skill · Python

推荐搜索词:麦当劳 MCP · mcd mcp · mcdonalds skill · 优惠券 优化 · 麦门 省钱


免责声明

本项目为麦当劳程序员创意开发大赛参赛作品,由参赛者独立开发,非麦当劳官方产品。 项目输出仅供参考,不构成医疗、营养或其他专业建议;餐品信息、价格及供应状态 以麦当劳官方渠道的实时结果为准。使用麦当劳 MCP 服务须遵守其《使用条款》与《麦当劳 MCP 服务规则》。

许可

MIT License(见 LICENSE)。

mcd-saver-strategist (hujjun/mcd-saver-strategist)

workbuddy
Searching Database…

What is this?mcd-saver-strategist (aka 'Mai Men Sheng Qian Jing Suan Shi') is an AI Agent Skill built on the McDonald's China MCP server that pulls a store's full menu and every available coupon, then runs a deterministic algorithm to find the cheapest valid order combo — for example turning a 47 yuan Big Mac meal into 21.9 yuan (53% off).
Is this a standalone app, or does it plug into an AI agent?It's an Agent Skill (built for WorkBuddy) paired with the McDonald's China MCP server, not a standalone chatbot — the skill is pure Python code with a deterministic optimizer, and an AI agent calls the MCP tools while this logic decides the actual order.
How can I try the optimizer without setting anything up?There's a built-in CLI demo with bundled sample data that runs the entire optimization flow offline, no MCP token required. To use it for real orders you plug the skill into WorkBuddy (or another agent) connected to the real McDonald's China MCP server.
Do I need a McDonald's MCP token to use it?Only for live menus, coupons, and real orders — that requires a McDonald's China MCP token and account access. The offline CLI demo needs nothing else: it's pure Python standard library with zero third-party dependencies.
Is the pricing data in this repo real-time?No — the menu prices and calorie figures shipped in the repo are example snapshots matching the MCP response structure for demo purposes; actual coupon availability and prices follow the live data returned by the real MCP server for your store and account.
Who is this especially useful for?Price-sensitive students and office workers, people watching calories while dieting, families or groups splitting a multi-person order, and frequent coupon users who want to know which coupons actually save money versus which ones are traps.
What optimization goals besides 'cheapest' does it support?It supports four order-planning goals — lowest price, maximum food quantity, lowest calories, and fewest store trips — always anchoring on the lowest achievable price and only trading up within a tolerance band, so it never suggests a wildly pricier 'more balanced' option.
What does the 'coupon audit' feature do?It checks each coupon against three figures — nominal face value, actual savings, and opportunity cost — to flag cases where a small coupon looks good alone but actually blocks you from a bigger combo deal like the '1+1' meal offer.
How does it decide what to add when I'm close to a discount threshold?It runs a subset-sum dynamic-programming search to find the minimum-cost item that closes the gap to the next discount tier, then reports the net change — which can even be negative, meaning adding an item actually saves you more money.
Why use a deterministic algorithm instead of letting the AI model estimate the price?All totals are computed by the optimizer or returned directly by the MCP server rather than guessed by the language model, avoiding hallucinated prices. The project backs this with 46 self-tests, 7 CI gates, and 17 checks keeping the web demo and skill logic in sync.
Which topics is it in?workbuddy, agent-skill, mcp-server, ai-agent, mcp, python
Creator
hujjun
Size
8.4 MB
Stars
608
Updated
CommitOct 17
Age
10d
Commits · 90 Days