FireBall1725/pcexpress-mcp-server

FireBall1725/pcexpress-mcp-server

Control your grocery cart with AI! This MCP server enables LLMs (like Claude) to search past orders, find products, and manage your shopping cart across all Loblaws-owned grocery banners.

Category
访问服务器

README

PC Express MCP Server

Unofficial Model Context Protocol (MCP) server for PC Express / Loblaws grocery shopping

Control your grocery cart with AI! This MCP server enables LLMs (like Claude) to search past orders, find products, and manage your shopping cart across all Loblaws-owned grocery banners.

License: AGPL v3 Python 3.10+

⚠️ Important Disclaimers

  • Unofficial: This project is NOT affiliated with, endorsed by, or supported by Loblaws Companies Limited, PC Express, or any related entities
  • Use at Your Own Risk: This uses an undocumented API that may change without notice
  • No Warranty: See LICENSE for details
  • Educational Purpose: This project demonstrates API reverse engineering and MCP server development

🛒 Supported Grocery Banners

Works with all PC Express enabled stores:

  • Zehrs - Ontario-based grocery chain
  • Loblaws - Main flagship banner
  • No Frills - Discount grocery banner
  • Real Canadian Superstore - Western Canada supermarket
  • Your Independent Grocer - Franchise stores
  • T&T Supermarket - Asian specialty supermarket

✨ Features

MCP Tools (6)

  1. search_past_orders - Find items from your order history
  2. get_order_items - Get detailed product list from specific orders
  3. search_products - Search the product catalog
  4. add_to_cart - Add products to your shopping cart
  5. remove_from_cart - Remove items from cart
  6. view_cart - See current cart contents

Integration Ready

  • Home Assistant - Voice-controlled grocery shopping
  • Claude Desktop - Chat with your grocery list
  • Custom Clients - Any MCP-compatible application

Voice Assistant Examples

🎤 "Add ice cream to my grocery cart"
🎤 "What did I order last week?"
🎤 "Search for organic bananas"
🎤 "What's in my cart?"

🚀 Quick Start

Prerequisites

  • Python 3.10 or higher
  • Active account with a PC Express enabled banner
  • pip or pip3

Installation

  1. Clone the repository

    git clone https://github.com/YOUR_USERNAME/pcexpress-mcp-server.git
    cd pcexpress-mcp-server
    
  2. Install dependencies

    pip install -r requirements.txt
    
  3. Configure credentials

    cp .env.example .env
    # Edit .env with your credentials (see Configuration section)
    
  4. Test the connection

    python test_api.py
    
  5. Run the server

    python pcexpress_mcp_server.py
    

⚙️ Configuration

Getting Your Credentials

Since there's no public API, you need to extract credentials from your browser session:

Method 1: HAR File Export (Recommended)

  1. Visit your banner's website (e.g., www.zehrs.ca)
  2. Log in to your account
  3. Open DevTools (F12) → Network tab
  4. ✅ Check "Preserve log"
  5. Clear network log
  6. Navigate to your cart and past orders
  7. Right-click in Network tab → "Save all as HAR with content"
  8. Run the credential extractor:
    python extract_credentials.py path/to/file.har
    

This automatically creates your .env file!

Method 2: Manual Extraction

See SETUP.md for detailed manual extraction instructions.

Environment Variables

# OAuth Bearer Token (expires after a few hours)
PCEXPRESS_BEARER_TOKEN=your_bearer_token_here

# Your customer/user ID
PCEXPRESS_CUSTOMER_ID=your_customer_id_here

# Your active cart ID
PCEXPRESS_CART_ID=your_cart_id_here

# Store ID (4-digit code)
PCEXPRESS_STORE_ID=your_store_id_here

# Banner: zehrs, loblaws, nofrills, superstore, independent, tandt
PCEXPRESS_BANNER=zehrs

🔌 Platform Integration

Home Assistant

# configuration.yaml
mcp:
  servers:
    - name: pcexpress
      command: python3
      args:
        - /path/to/pcexpress_mcp_server.py
      env:
        PCEXPRESS_BEARER_TOKEN: "your_token"
        PCEXPRESS_CUSTOMER_ID: "your_id"
        PCEXPRESS_CART_ID: "your_cart"
        PCEXPRESS_STORE_ID: "your_store"
        PCEXPRESS_BANNER: "zehrs"

Claude Desktop

Edit your Claude Desktop config:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "pcexpress": {
      "command": "python3",
      "args": ["/path/to/pcexpress_mcp_server.py"],
      "env": {
        "PCEXPRESS_BEARER_TOKEN": "your_token",
        "PCEXPRESS_CUSTOMER_ID": "your_id",
        "PCEXPRESS_CART_ID": "your_cart",
        "PCEXPRESS_STORE_ID": "your_store",
        "PCEXPRESS_BANNER": "zehrs"
      }
    }
  }
}

Restart Claude Desktop and start chatting about groceries!

Custom MCP Client

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(
    command="python3",
    args=["pcexpress_mcp_server.py"],
    env={
        "PCEXPRESS_BEARER_TOKEN": "your_token",
        # ... other env vars
    }
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()

        # List available tools
        tools = await session.list_tools()

        # Call a tool
        result = await session.call_tool("search_products", {
            "query": "ice cream"
        })

📚 Documentation

⚠️ Known Limitations

1. Token Expiration

Problem: Bearer tokens expire after a few hours

Impact: Server stops working when token expires

Workaround: Re-extract credentials from browser session

Status: ❌ Not solved - Long-term authentication not yet implemented

See #1 - Implement automatic token refresh

2. Product Search Limitations

Problem: Type-ahead search only returns category suggestions, not actual products

Impact: Can't directly get product codes for adding to cart

Workaround: Use past orders to find product codes

Status: 🔍 Investigating alternative endpoints

3. Cart ID Changes

Problem: Cart ID may change on logout/login

Impact: Server needs cart ID updated

Workaround: Re-extract credentials

Status: ⚠️ Needs cart merging implementation

4. No Official API

Problem: Using reverse-engineered, undocumented API

Impact: May break if Loblaws changes their API

Workaround: Monitor for changes, update accordingly

Status: ⚠️ Inherent limitation

5. Store-Specific Inventory

Problem: Product availability varies by store location

Impact: Search results depend on selected store

Workaround: Ensure correct PCEXPRESS_STORE_ID is set

Status: ✅ Expected behavior

🐛 Troubleshooting

"401 Unauthorized"

Cause: Token expired or invalid

Fix: Re-extract credentials from browser

"404 Not Found"

Cause: Cart/Customer ID changed or wrong banner

Fix: Verify PCEXPRESS_BANNER matches token source, re-extract IDs

"No products found"

Cause: Store doesn't carry product or wrong store ID

Fix: Verify PCEXPRESS_STORE_ID is correct

Tests fail

Cause: Missing dependencies or invalid credentials

Fix:

pip install -r requirements.txt
python extract_credentials.py your_file.har

See full troubleshooting guide in SETUP.md

🗺️ Roadmap

High Priority

  • [ ] Automatic token refresh (#1)
  • [ ] Full product search (not just type-ahead) (#2)
  • [ ] Cart ID change detection (#3)
  • [ ] Better error messages (#4)

Medium Priority

  • [ ] Shopping list management
  • [ ] PC Optimum points integration
  • [ ] Checkout/order placement
  • [ ] Product details (images, nutrition, etc.)
  • [ ] Price tracking

Low Priority

  • [ ] Multiple banner support in single instance
  • [ ] Recipe suggestions based on cart
  • [ ] Price comparison across banners

See Issues for full list.

🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

Quick Contribution Guide

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Test thoroughly (python test_api.py)
  5. Commit (git commit -m 'Add amazing feature')
  6. Push (git push origin feature/amazing-feature)
  7. Open a Pull Request

📜 License

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

🙏 Acknowledgments

  • Thanks to the MCP protocol team at Anthropic
  • Inspired by the need for better grocery shopping automation
  • Built with reverse-engineering and determination

⚖️ Legal

This project is provided for educational and personal use only.

  • Not affiliated with Loblaws Companies Limited
  • Uses undocumented API - use at your own risk
  • May violate Terms of Service - check before using
  • No warranty or guarantee of functionality
  • Author not responsible for any consequences of use

By using this software, you agree to take full responsibility for your usage.

📧 Contact


Made with ❤️ for better grocery shopping

If this project saved you time, consider starring ⭐ the repo!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选