杂货购物自动化工具

一个通过自然语言对话连接Claude与H-E-B超市的MCP服务器,实现商品搜索、购物车管理、优惠券剪贴等功能。

  • by mgwalkerjr95
  • Python
  • 本地部署
  • 68 星标
  • 更新于
在 GitHub 查看 mgwalkerjr95/texas-grocery-mcp

使用说明

🛒 得克萨斯州杂货MCP

🤖 让AI帮你买杂货!连接克劳德和H-E-B杂货店的MCP服务器。

搜索产品、管理购物车、剪辑优惠券等等——所有这些都是通过自然对话完成的。

⚠️ 这个项目是 不属于H-E-B。它使用非官方的web API和浏览器自动化来对抗HEB.com;负责任地使用,并确保您的使用符合适用的条款和法律。


✨ 特性

特性 描述
🏪 店铺搜索 按地址或邮政编码查找HEB商店
🔍 产品搜索 搜索具有价格和可用性的产品
🛒 购物车管理 使用人工在循环中确认添加/删除项目
📋 产品详情 成分、营养成分、过敏原、警告
🎟️ 数字优惠券 列出、搜索和剪辑优惠券以节省资金
🔄 自动会话刷新 自动处理机器人检测(约15秒)

📦 安装

快速开始

pip install texas-grocery-mcp

完整安装(推荐)🚀

pip install texas-grocery-mcp[browser]
playwright install chromium

这使得 快速自动刷新 (约15秒)使用嵌入式浏览器。

先决条件

对于购物车操作和会话管理,您还需要 剧作家MCP:

npm install -g @anthropic-ai/mcp-playwright

⚙️ 配置

克劳德桌面版

添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@anthropic-ai/mcp-playwright"]
    },
    "heb": {
      "command": "uvx",
      "args": ["texas-grocery-mcp"],
      "env": {
        "HEB_DEFAULT_STORE": "590"
      }
    }
  }
}

环境变量

变量 描述 默认值
HEB_DEFAULT_STORE 默认商店ID 无
REDIS_URL Redis缓存URL 无(内存中)
LOG_LEVEL 日志记录级别 信息

🎯 用法示例

🏪 寻找店铺

User: Find HEB stores near Austin, TX

Agent uses: store_search(address="Austin, TX", radius_miles=10)

🔍 搜索产品

User: Search for organic milk

Agent uses: store_change(store_id="590")
Agent uses: product_search(query="organic milk")

📋 获取产品详细信息

User: What are the ingredients in H-E-B olive oil?

Agent uses: product_search(query="heb olive oil")
Agent uses: product_get(product_id="127074")
# Returns: ingredients, nutrition facts, warnings, dietary attributes

这 product_get 工具返回:

  • 🥗 配料 -完整成分说明
  • 📊 营养成分表 -完整的FDA小组
  • ⚠️ 安全警告 -过敏原信息和预防措施
  • 🌿 饮食属性 -无麸质、有机、纯素、犹太洁食等。
  • 📍 存储位置 -过道或区间

🛒 添加到购物车

User: Add 2 gallons of milk to my cart

Agent uses: cart_add(product_id="123456", quantity=2)
# Returns preview for confirmation

Agent uses: cart_add(product_id="123456", quantity=2, confirm=true)
# ✅ Added to cart!

🎟️ 剪贴优惠券

User: Find coupons for cereal

Agent uses: coupon_search(query="cereal")
Agent uses: coupon_clip(coupon_id="ABC123", confirm=true)
# ✅ Coupon clipped!

🔐 会话管理

HEB使用机器人检测,每11分钟过期一次。这个MCP会自动处理它!

⚡ 快速自动刷新(推荐)

随着 [browser] 已安装支架:

Agent uses: session_refresh()
# ✅ Completes in ~10-15 seconds

🔑 自动登录

保存一次凭据以自动登录:

Agent uses: session_save_credentials(email="you@email.com", password="...")
# Credentials stored securely in system keyring
# Future session refreshes will auto-login!

🧰 可用工具

🏪 存储工具

工具 说明
store_search 按地址查找商店
store_change 设置首选商店
store_get_default 获取当前默认存储

🔍 产品工具

工具 说明
product_search 搜索有定价的产品
product_search_batch 搜索多个产品(最多20个)
product_get 获取详细的产品信息

🛒 购物车工具

工具 说明
cart_check_auth 检查身份验证状态
cart_get 查看购物车内容
cart_add 添加项目(需要确认)
cart_add_many 批量添加多个项目
cart_remove 删除项目

🎟️ 优惠券工具

工具 说明
coupon_list 列出可用优惠券
coupon_search 按关键字搜索优惠券
coupon_clip 剪一张优惠券
coupon_clipped 列出您剪下的优惠券

🔐 会话工具

工具 说明
session_status 检查会话运行状况
session_refresh 刷新/登录会话
session_save_credentials 保存用于自动登录的凭据
session_clear 注销

📚 文档


🛠️ 发展

# Clone repository
git clone https://github.com/mgwalkerjr95/texas-grocery-mcp
cd texas-grocery-mcp

# Install with dev dependencies
pip install -e ".[dev]"
playwright install chromium

# Run tests
pytest tests/ -v

# Linting & type checking
ruff check src/
mypy src/

🐳 码头工人

docker-compose up --build

🏗️ 建筑

┌─────────────────────────────────────────────────────────────┐
│                    User's MCP Environment                    │
│                                                             │
│  ┌─────────────────────┐    ┌─────────────────────────────┐ │
│  │  🎭 Playwright MCP  │    │   🛒 Texas Grocery MCP      │ │
│  │  (Browser Auth)     │───▶│   (Grocery Logic)           │ │
│  └─────────────────────┘    └─────────────────────────────┘ │
│                                        │                     │
└────────────────────────────────────────┼─────────────────────┘
                                         │
                                         ▼
                                   🌐 HEB GraphQL API

📄 许可证

麻省理工学院©迈克尔·沃克


Made with ❤️ in Texas 🤠