Swiggy MCP服务器
用于Swiggy食品配送的MCP(模型上下文协议)服务器-浏览餐厅、管理购物车、申请优惠券和通过UPI付款。
⚠️ 重要提示:需要浏览器集成
此MCP需要浏览器集成来刷新WAF令牌。Swiggy使用AWS WAF保护,该保护要求浏览器生成的令牌每约15分钟过期一次。
浏览器集成的两个选项:
选项1:克劳德代码Chrome集成(推荐)
Claude Code通过Claude in Chrome扩展程序内置了Chrome集成。
先决条件:
- 谷歌浏览器
- Chrome扩展程序中的Claude v1.0.36+
- 克劳德代码v2.0.73+(
claude --version检查)
用途:
# Start Claude Code with Chrome enabled
claude --chrome然后让Claude在需要时刷新Swiggy令牌-它将导航到Swiggy.com并自动捕获新的Cookie。
查看完整文档:https://code.claude.com/docs/en/chrome
选项2:Chrome DevTools MCP
或者,使用单独的Chrome DevTools MCP服务器。
添加到Claude桌面配置:
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-chrome-devtools@latest"]
}
}
}设置
1.安装Swiggy MCP
git clone https://github.com/ChakshuGautam/swiggy-mcp.git
cd swiggy-mcp
npm install
npm run build2.配置克劳德桌面
添加 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"swiggy": {
"command": "node",
"args": ["/path/to/swiggy-mcp/dist/index.js"]
}
}
}3.初始设置
- 打开Chrome浏览器并导航到https://www.swiggy.com
- 登录您的Swiggy帐户
- 使用以下代码启动Claude代码
claude --chrome - 让克劳德刷新Swiggy代币
配置文件
代币存储在 ~/.swiggy.json:
{
"wafToken": "...",
"cookies": "...",
"userId": 12345,
"csrfToken": "...",
"deviceId": "...",
"sid": "...",
"tid": "...",
"userLocation": {
"lat": "18.5108123",
"lng": "73.7803971",
"address": "Bavdhan, Pune"
}
}可用工具
餐厅发现
| 工具 | 说明 |
|---|---|
list_restaurants | 列出附近的餐馆 |
get_restaurant_menu | 获取包含价格的完整菜单 |
search_suggestions | 搜索食物/餐馆 |
search_restaurants | 使用筛选器搜索 |
get_nearby_restaurants | 附近餐馆的列表 |
check_serviceability | 检查餐厅是否送货上门 |
购物车管理
| 工具 | 说明 |
|---|---|
get_cart | 获取当前购物车(商品、总数) |
add_to_cart | 将商品添加到购物车 |
update_cart_item | 更新项目数量 |
clear_cart | 清除所有项目 |
优惠券
| 工具 | 说明 |
|---|---|
get_available_coupons | 列出可用优惠券 |
apply_coupon | 应用优惠券代码 |
remove_coupon | 删除已申请的优惠券 |
付款(UPI)
| 工具 | 说明 |
|---|---|
get_saved_payment_methods | 获取已保存的UPI ID和卡片 |
initiate_upi_payment | 启动UPI代收付款 |
check_payment_status | 付款审批投票 |
confirm_order | 付款成功后确认 |
会话管理
| 工具 | 说明 |
|---|---|
update_session | 更新cookies/WAF令牌 |
update_waf_token | 仅更新WAF令牌 |
clear_cache | 清除缓存数据 |
用法示例
浏览和订购
User: What restaurants are nearby?
Claude: [Uses get_nearby_restaurants]
User: Show me the menu for Domino's
Claude: [Uses get_restaurant_menu]
User: Add 2 Margherita pizzas to cart
Claude: [Uses add_to_cart]
User: Apply best coupon
Claude: [Uses get_available_coupons, then apply_coupon]
User: Pay with my UPI
Claude: [Uses get_saved_payment_methods, initiate_upi_payment]
→ Sends notification to your Google Pay
[Polls check_payment_status until you approve]
[Uses confirm_order after success]令牌刷新流程
当你看到 WAF_TOKEN_EXPIRED:
Claude: [Opens swiggy.com in Chrome]
[Captures network request with fresh cookies]
[Uses update_session to save new tokens]
[Retries the original request]响应格式
所有响应只返回基本数据(没有原始API膨胀):
{
"restaurantId": "217027",
"restaurantName": "Domino's Pizza",
"items": [
{"name": "Margherita", "quantity": 2, "price": 398, "itemId": "123"}
],
"itemTotal": 398,
"discount": 100,
"couponCode": "SWIGGYIT",
"orderTotal": 350
}AWS WAF保护
Swiggy使用AWS WAF保护大多数端点。需要浏览器集成来:
- 在真实浏览器中导航到swiggy.com
- 让浏览器解决WAF挑战
- 捕捉结果
aws-waf-token曲奇 - 将其用于后续API调用
令牌每约15分钟过期一次,需要定期刷新。
故障排除
“WAF_TOKEN_EXPIRED”错误
- 确保Chrome已通过swiggy.com打开
- 跑
claude --chrome并要求刷新令牌 - 或者使用Chrome DevTools MCP捕获新的Cookie
“餐厅不可用”
- 使用
check_serviceability添加到购物车之前 - 餐厅可能无法送货到您保存的地址
付款不起作用
- 确保您已在Chrome中登录Swiggy
- 您的UPI ID必须保存在Swiggy帐户中
- 检查购物车是否有商品,地址是否已设置
许可证
麻省理工学院
