waimaigo-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
waimaigo-mcp
把「校园外卖购」(微信小程序 wxc160ec9bc06331c6,广州工商学院三水校区)的接口封装成 MCP 服务器。
覆盖完整链路:登录态 → 选食堂 → 选店 → 看菜单 → 精确报价 → 下单 → 查单 → 支付参数 / 取消。
⚠️ 免责声明 本项目是个人学习用的接口封装,与「校园外卖购」运营方、微信、任何学校均无关。 接口来自对公开客户端的协议分析,可能在任何时候失效。 本项目不包含任何服务端密钥(见下文),也不提供绕过支付的手段。 使用自动化方式下单可能违反平台服务条款;请仅用于你自己的账号、自行判断风险。一切后果由使用者自行承担。
一、先说清楚边界
能做 | 不能做 |
查食堂 / 店铺 / 菜单 / 价格 | ❌ 拿到微信支付参数后代你付钱 |
精确报价(商品 + 餐盒 + 配送 + 起送价) | ❌ 用别人的 token / 账号 |
生成真实订单、查单、取消 | ❌ 绕过小程序的支付流程 |
拿 | — |
pay_order 能拿到完整的微信 JSAPI 参数(appId / timeStamp / nonceStr / package / paySign),
但 wx.requestPayment 只能在微信小程序里调用,外部拿不到。所以真实流程是:
MCP 帮你查+算+下单 → 你自己在微信小程序里点一下付款 → 不付的话 2 小时后自动取消,不扣钱。
Related MCP server: kfc-cn-mcp
二、本仓库不含任何密钥
server.py 里的 SM2 加解密需要一对密钥。开源版本已把私钥从源码里移除,仓库里只有公钥(公钥本身不是秘密)。
要用签名/加密相关的接口,请自行提供私钥,位置三选一:
# 1) 环境变量
export WAIMAIGO_SM2_KEY=<64 位 hex>
# 2) 文件(整个文件就是 hex 串)
~/.waimaigo/sm2.txt
# 3) JSON 文件
~/.waimaigo/sm2.json -> { "privateKey": "<64 位 hex>" }没有密钥时,服务仍能正常启动,只有需要加解密的工具会返回明确错误——不会静默失败。
你要用哪把密钥、从哪来、是否拥有合法使用权,由你自己判断并承担后果。
三、16 个工具
工具 | 作用 |
login_guide | 先调这个:要不要登录、怎么拿 token、下一步做什么 |
login_status | token 有效期、user_id、手机号、余额 |
login_use_token | 直接写入一个 JWT 并校验 |
login_import_text | 从 HAR / 日志 / curl / Network 复制的一堆文本里自动挑 token |
login_by_oauth2_code | 用小程序 |
list_canteens | 食堂清单(三饭=23、一饭=29、二饭=21、四饭=30、正德广场=32、沁湖轩=31、公寓=41) |
list_stores | 某食堂/全校区店铺,带营业状态、评分、月售 |
get_menu | 菜单 → 分类 / 商品 / 规格( |
list_addresses | 收货地址( |
quote | 精确报价:商品小计 + 餐盒 + 商家配送 + 平台配送 + 合计 + 够不够起送 |
create_order | 下单; |
list_orders | 我的订单 |
get_order | 单笔订单详情 |
pay_order | 调 doPay,拿微信 JSAPI 支付参数(你自己付) |
query_pay_status | 查支付状态 |
cancel_order | 取消订单 |
四、安装
需要 Python 3.10+(实测 3.12)。
git clone https://github.com/yjp-jdp/waimaigo-mcp.git
cd waimaigo-mcp
python -m venv .venv
# Windows: .venv\Scripts\activate
source .venv/bin/activate
pip install -r requirements.txt
requirements.txt锁了mcp<2:mcp 2.x 把FastMCP改名成MCPServer,本代码是 1.x 写法。
启动(stdio):
python server.py五、token 从哪来(核心难点)
小程序唯一登录接口是 POST /index/getTokenByOauth2Code,入参 {code, referrer_id, from:"WECHAT_MINI", unionid},
code 必须由小程序里的 wx.login() 现场生成 —— 外部脚本拿不到。所以只能复用小程序已经拿到的 token:
一键抓(最省事):装 mitmproxy,跑
mitmdump -s grab_token.py --listen-port 8080把系统/手机代理指到
127.0.0.1:8080,在微信里打开小程序点一下首页, 插件从Authorization头里认出 JWT(校验iss=waimaigo且未过期)→ 自动落盘到~/.waimaigo/token.json。文本导入:把 HAR / 抓包日志 / curl / 浏览器 Network 复制整段丢给
login_import_text。手动贴:
login_use_token(token=...),值就是eyJ开头那串。
存放:~/.waimaigo/token.json,有效期约 13 天,过期重抓。
六、接入 MCP 客户端
{
"mcpServers": {
"waimaigo": {
"command": "/绝对路径/waimaigo-mcp/.venv/Scripts/python.exe",
"args": ["/绝对路径/waimaigo-mcp/server.py"],
"cwd": "/绝对路径/waimaigo-mcp"
}
}
}macOS / Linux 把
command换成/绝对路径/waimaigo-mcp/.venv/bin/python。
DeepSeek Harness(~/.dsh/cordis.patch.yml):
- insert:
- id: waimaigo-mcp
name: "@deepseek-ai/dsh-mcp-client"
config:
serverName: waimaigo
transport: stdio
command: '/绝对路径/waimaigo-mcp/.venv/Scripts/python.exe'
args:
- '/绝对路径/waimaigo-mcp/server.py'
cwd: '/绝对路径/waimaigo-mcp'
toolCallTimeoutMs: 180000七、查餐的标准动作
list_canteens → 食堂对照(三饭 = 23)
list_stores(canteen="三饭") → 店铺 + 营业状态 + 评分 + 月售
get_menu(business_id) → 分类 / 商品 / 规格 gs_id / 单价
quote(business_id, items, address_id) → 商品小计 + 餐盒 + 配送 + 合计 + 够不够起送items格式:[{"g_id": 77571, "gs_id": 106313, "number": 1}]店铺
b_rest != 1表示打烊价格全部来自实时接口
八、已知限制
付款最后一步做不到(见第一节)
余额支付需要先在小程序里充值并设置支付密码
服务端未强制校验
api_sign,只补了api_norce_str / api_timestamp接口是逆向合约:运营方改版可能直接失效
九、目录结构
waimaigo-mcp/
├── server.py # MCP 服务本体(FastMCP,stdio)
├── grab_token.py # mitmproxy 插件:打开小程序就把 token 抓下来
├── requirements.txt
├── AGENTS.md # 给 AI 读的使用规矩(先读再让它动手)
└── SETUP.md # 给人看的大白话三步走相关项目
同一套学校系统工具集的其它仓库(各自独立、可单独安装):
gzgs-jwcli — 教务系统:课表、成绩、考试、调课(MCP + CLI)
gzgs-xgxt-mcp — 学工系统:综测明细、五进手册(纯只读)
chaoxing-mcp — 学习通:作业查询、附件上传、存草稿
许可
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Order food from Cordering white-label restaurants: browse menus, confirm, then place an order.
Per-restaurant MCP servers: menu, hours, delivery terms; live example below
Run a restaurant's QR menu: items, prices, sold out, languages, photos, orders and sales.
Restaurant management API for meni.ge owners: manage menus, locations, orders, and settings.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceProvides a local-first Chinese dietary coaching server that reviews meals, recomputes nutrition from bundled food data, and manages user profiles and meal history in a private local SQLite database.MIT
- AlicenseAqualityCmaintenanceEnables ordering from KFC China through official H5 JSON APIs, including finding stores, browsing menus, managing a cart, previewing checkout, and submitting real unpaid orders.14MIT
- AlicenseBqualityBmaintenanceA local-first stdio MCP server that lets personal agents use user-authorized McDonald's China accounts to browse stores and menus, verify discounts, place pickup orders, and pay with McWallet under local spending policies. It provides account/session checks, cart configuration, quote verification, idempotent checkout, and order-status tools while keeping credentials and policy management local.17MIT
- AlicenseAqualityBmaintenanceEnables ordering food from KFC China through its official H5 JSON APIs: finding stores, browsing and searching the menu, managing a cart, previewing checkout, and submitting real orders with explicit user confirmation, compatible with Hermes and any stdio-based MCP client.15MIT