← Back to documentation

Building an AI Shopping Assistant with BuyWhere MCP

By: Blog

Step-by-step guide to creating an AI-powered shopping assistant using Claude Desktop and BuyWhere's Model Context Protocol (MCP) integration

Building an AI Shopping Assistant with BuyWhere MCP

Learn how to create an intelligent shopping assistant that can search products, compare prices, and generate personalized recommendations using Claude Desktop and BuyWhere's Model Context Protocol (MCP) integration.

Introduction

The Model Context Protocol (MCP) is revolutionizing how AI models interact with external tools and data sources. By exposing the BuyWhere product catalog as MCP tools, we enable AI models like Claude to seamlessly search, filter, and compare products across Singapore's e-commerce platforms without complex API integrations.

In this tutorial, we'll build a complete AI shopping assistant that helps users find the best products at the best prices, all through natural language conversation with Claude Desktop.

Prerequisites

Before we begin, ensure you have:

  1. Claude Desktop installed (download link)
  2. BuyWhere API key (get one at https://buywhere.ai/api-keys)
  3. Python 3.10+ installed
  4. Git for cloning the repository (optional)

Step 1: Set Up the BuyWhere MCP Server

The BuyWhere MCP server acts as a bridge between Claude Desktop and the BuyWhere product catalog API.

Option A: Using the Pre-built Package (Recommended)

pip install buywhere-mcp

Option B: Running from Source

# Clone the repository
git clone https://github.com/buywhere/buywhere-api.git
cd buywhere-api

# Install dependencies
pip install -e .

# Install MCP-specific dependencies
pip install mcp[cli]

Step 2: Configure the MCP Server

Create a configuration file for the MCP server at ~/.config/buywhere/mcp.json:

{
  "mcpServers": {
    "buywhere": {
      "command": "buywhere-mcp",
      "args": [],
      "env": {
        "BUYWHERE_API_KEY": "bw_live_your_api_key_here",
        "BUYWHERE_API_URL": "https://api.buywhere.ai",
        "BUYWHERE_MCP_HTTP_PORT": "8080"
      }
    }
  }
}

Replace bw_live_your_api_key_here with your actual BuyWhere API key.

Step 3: Configure Claude Desktop

Add the MCP server to your Claude Desktop configuration:

macOS

Edit ~/Library/Application Support/Claude/claude_desktop_config.json

Windows

Edit %APPDATA%\Claude\claude_desktop_config.json

Add the following configuration:

{
  "mcpServers": {
    "buywhere": {
      "command": "buywhere-mcp",
      "env": {
        "BUYWHERE_API_KEY": "bw_live_your_api_key_here"
      }
    }
  }
}

Important: Restart Claude Desktop after making changes to the configuration file.

Step 4: Verify the Connection

Once Claude Desktop restarts, you should see the BuyWhere MCP server connected. You can verify this by asking Claude:

What tools are available?

Claude should respond with a list of available BuyWhere MCP tools:

  • search - Natural language product search
  • get_product - Retrieve a specific product by ID
  • compare_prices - Search products sorted by price for comparison
  • get_deals - Find discounted products
  • browse_categories - Browse category taxonomy tree
  • get_category_products - Get products within a category
  • find_deals - Find the best current deals

Step 5: Building Your First Shopping Query

Let's start with a simple product search. Ask Claude:

Search BuyWhere for wireless headphones under SGD 200 in Singapore.

Claude will invoke the search MCP tool and return structured results like:

Here are some wireless headphones under SGD 200:

1. **Sony WH-CH720N** | SGD 179.00 | Shopee SG | ⭐ 4.2 (1,234 reviews)
   - Noise cancelling, 35hr battery life
   - Buy: https://api.buywhere.ai/v1/track/abc123

2. **JBL Tune 510BT** | SGD 129.00 | Lazada SG | ⭐ 4.0 (856 reviews)
   - Wireless, 40hr battery life
   - Buy: https://api.buywhere.ai/v1/track/def456

3. **Anker Soundcore Life Q20** | SGD 149.00 | Amazon SG | ⭐ 4.3 (2,109 reviews)
   - Hybrid noise cancelling, 40hr battery life
   - Buy: https://api.buywhere.ai/v1/track/ghi789

Step 6: Comparing Prices Across Platforms

Now let's find the best price for a specific product. Ask Claude:

Compare prices for Apple AirPods Pro (2nd generation) across all Singapore platforms.

Claude will use the compare_prices tool to search and sort by price:

Price comparison for Apple AirPods Pro (2nd generation):

🏆 **Best Price: SGD 249.00** | Shopee SG
   - In stock, free shipping
   - ⭐ 4.5 (3,421 reviews)
   - Buy: https://shopee.sg/apple-airpods-pro-2

2. **SGD 269.00** | Lazada SG
   - In stock, free shipping over SGD 40
   - ⭐ 4.4 (2,109 reviews)
   - Buy: https://lazada.sg/apple-airpods-pro-2

3. **SGD 289.00** | Amazon SG
   - Prime eligible, free shipping
   - ⭐ 4.6 (5,678 reviews)
   - Buy: https://amazon.sg/apple-airpods-pro-2

4. **SGD 299.00** | Challenger SG
   - In-store pickup available
   - ⭐ 4.3 (876 reviews)
   - Buy: https://challenger.com.sg/apple-airpods-pro-2

**Savings**: You save SGD 50.00 (17%) by choosing Shopee over Challenger.

Step 7: Finding the Best Deals

Let's discover current promotions and discounts. Ask Claude:

Show me the best deals on electronics under SGD 100.

Claude will use the get_deals and find_deals tools:

Here are the best electronics deals under SGD 100:

🔥 **FLASH DEAL: Xiaomi Mi Band 7** | SGD 59.00 (was SGD 99.00)
   - 40% off - Today only!
   - ⭐ 4.4 (5,678 reviews) | Shopee SG
   - Buy: https://shopee.sg/xiaomi-mi-band-7

🔥 **Anker PowerCore 10000mAh** | SGD 79.00 (was SGD 129.00)
   - 39% off - Free shipping
   - ⭐ 4.6 (8,901 reviews) | Lazada SG
   - Buy: https://lazada.sg/anker-powercore-10000

🔥 **JBL Tune 125TWS Earbuds** | SGD 89.00 (was SGD 149.00)
   - 40% off - Cashback available
   - ⭐ 4.3 (3,210 reviews) | Amazon SG
   - Buy: https://amazon.sg/jbl-tune-125tws

Step 8: Building a Shopping Recommendation Engine

Let's combine multiple tools to create intelligent recommendations. Ask Claude:

I need a gift for my tech-savvy friend who loves photography. Budget: SGD 150-250. What do you recommend?

Claude will:

  1. Search for photography-related products
  2. Filter by price range
  3. Check ratings and availability
  4. Generate personalized recommendations

Here's what Claude might suggest:

Based on your criteria (tech-savvy friend, photography interest, SGD 150-250 budget), here are my top recommendations:

📸 Best Overall: DJI OM 5 Smartphone Gimbal

  • Price: SGD 199.00 (normally SGD 229.00)
  • Platform: Lazada SG
  • Rating: ⭐ 4.7 (4,321 reviews)
  • Why it's great: 3-axis stabilization, extension rod, built-in tripod, perfect for vlogging and steady shots
  • Buy: https://lazada.sg/dji-om-5-gimbal

📷 Runner-Up: SanDisk Extreme Pro 128GB SD Card

  • Price: SGD 24.90 × 2 packs = SGD 49.80
  • Platform: Shopee SG
  • Rating: ⭐ 4.8 (12,403 reviews)
  • Why it's great: UHS-I U3, V30, 4K video capable - essential for photographers
  • Note: Buy two for extra storage flexibility
  • Buy: https://shopee.sg/sandisk-extreme-pro-128gb

💡 Budget Pick: Neewer 2-Pack LED Video Light

  • Price: SGD 89.00
  • Platform: Amazon SG
  • Rating: ⭐ 4.5 (2,109 reviews)
  • Why it's great: Adjustable color temperature, includes stands and diffusers - great for product photography
  • Buy: https://amazon.sg/neewer-led-video-light

Total value: You could get the gimbal + memory cards + lights for ~SGD 337.80, but starting with the gimbal (SGD 199) gives you the core photography enhancement within your budget.

Step 9: Advanced Features - Category Browsing

Let's explore products by category. Ask Claude:

Show me the top 5 best-selling cameras in the Electronics > Cameras category.

Claude will use browse_categories to find the category ID, then get_category_products:

Top 5 Best-Selling Cameras in Singapore:

1. **Canon EOS R50** | SGD 899.00 | Sony Store SG | ⭐ 4.6 (1,203 reviews)
   - Mirrorless APS-C, 24.2MP, 4K 30p video
   - Kit includes RF-S 18-45mm f/4.5-6.3 IS STM lens

2. **Nikon Z30** | SGD 799.00 | Nikon SG | ⭐ 4.5 (987 reviews)
   - Mirrorless DX-format, 20.9MP, 4K UHD video
   - Great for beginners and content creators

3. **Fujifilm X-S20** | SGD 1,299.00 | Harvey Norman SG | ⭐ 4.7 (654 reviews)
   - APS-C 26.1MP, 6.2K 30p video, excellent for hybrid shooters
   - Known for superb color science and film simulations

4. **Olympus OM-D E-M10 Mark IV** | SGD 699.00 | Challenger SG | ⭐ 4.4 (1,102 reviews)
   - Micro Four Thirds, 20.3MP, 5-axis image stabilization
   - Excellent value with great ergonomics

5. **Panasonic Lumix G100** | SGD 749.00 | Best Denki SG | ⭐ 4.3 (876 reviews)
   - Micro Four Thirds, 20.3MP, optimized for vlogging
   - Includes 12-32mm lens, great audio capabilities

**Trend**: Mirrorless cameras dominate the market, with Sony, Canon, and Nikon leading sales in Singapore.

Step 10: Creating a Price Tracking Alert

Let's build a simple price tracking mechanism. Ask Claude:

Track the price of Samsung Galaxy S24 Ultra and alert me when it drops below SGD 1,400.

While Claude can't set up persistent alerts (that would require a background service), it can help you create a checking routine:

I'll help you check the current price and show you how to track it manually.

**Current Price Check for Samsung Galaxy S24 Ultra:**

🔍 Searching across all platforms...

**Current Prices:**
- **SGD 1,599.00** | Samsung SG Official Store (Lowest)
- **SGD 1,649.00** | Lazada SG
- **SGD 1,699.00** | Shopee SG
- **SGD 1,749.00** | Amazon SG

**Price Tracking Strategy:**
1. **Daily Check**: Ask Claude each morning: "What's the current price of Samsung Galaxy S24 Ultra?"
2. **Price History**: Note down prices over time to identify trends
3. **Alert Threshold**: You're targeting SGD 1,400 - that's about a 12.5% drop from current lowest
4. **Best Times to Check**: 
   - Major sales events (11.11, 12.12, CNY, Great Singapore Sale)
   - End of month (retailers clearing inventory)
   - New model announcements (typically February for S-series)

**Recommendation**: Check prices twice weekly and consider setting a calendar reminder for major sales events.

Step 11: Building a Complete Shopping Workflow

Let's put it all together with a comprehensive shopping assistant workflow. Ask Claude:

Help me find the best laptop for programming under SGD 1,800. I need at least 16GB RAM, SSD storage, and good battery life.

Claude will execute a multi-step process:

Let me help you find the ideal programming laptop within your budget. I'll break this down into steps:

**Step 1: Search for laptops with programming-friendly specifications**
[Calling search tool with query="laptop programming 16GB RAM SSD", max_price=1800, limit=15]

**Step 2: Filter and analyze results**
Based on the search results, I'll focus on machines with:
- Minimum 16GB RAM (preferably upgradeable)
- SSD storage (256GB+ recommended)
- Good battery life (6+ hours for mobility)
- Recent generation processors (Intel i5/i7/Ryzen 5/7 or better)

**Step 3: Present top recommendations**

Here are my top picks for programming laptops under SGD 1,800:

### 🏆 **Best Value: Lenovo IdeaPad Slim 7 Pro 14"**
- **Price**: SGD 1,699.00
- **Specs**: AMD Ryzen 7 7840HS, 16GB RAM, 512GB SSD, 14.5" 2.8K 90Hz display
- **Battery**: Up to 10 hours
- **Why great for programming**: Excellent CPU performance, great display for code, lightweight (1.39kg)
- **Platform**: Lenovo SG Official Store
- **Buy**: https://lenovo.sg/ideapad-slim-7-pro

### 🥈 **Runner-Up: ASUS Vivobook Pro 15 OLED**
- **Price**: SGD 1,799.00
- **Specs**: Intel i7-13650HX, 16GB RAM, 512GB SSD, 15.6" 2.8K OLED 120Hz display
- **Battery**: Up to 7 hours
- **Why great for programming**: Stunning color-accurate display, powerful CPU, good port selection
- **Platform**: ASUS SG Official Store
- **Buy**: https://asus.sg/vivobook-pro-15-oled

### 🥉 **Budget Option: Acer Swift X SFX14-41G**
- **Price**: SGD 1,599.00
- **Specs**: AMD Ryzen 7 7730U, 16GB RAM, 512GB SSD, 14" FHD display
- **Battery**: Up to 8 hours
- **Why great for programming**: Good balance of performance and portability, dedicated GPU for light graphics work
- **Platform**: Harvey Norman SG
- **Buy**: https://harveynorman.sg/acer-swift-x

**Key Considerations for Programming:**
1. **RAM**: 16GB is the sweet spot for most programming tasks (VMs, containers, large codebases)
2. **Storage**: SSD is essential for fast boot times and quick project loading
3. **Display**: Consider resolution and color accuracy if you do UI/UX work
4. **Portability**: Weight matters if you commute or work from cafes
5. **OS**: Most laptops come with Windows 11 - great for .NET development, consider Linux dual-boot if needed

**Next Steps**: 
- Check specific software requirements (some tools may need specific OS versions)
- Consider external monitor setup for extended screen real estate
- Look for student discounts if applicable (many brands offer 10-15% off)

Code Examples: Using BuyWhere MCP Programmatically

While the MCP integration works naturally with Claude Desktop, you can also use the BuyWhere MCP server programmatically in your Python applications. Here's how:

Example 1: Basic Product Search

import asyncio
from mcp import stdio_client, StdioServerParameters
from mcp.client.session import ClientSession

async def search_products():
    # Set up connection to MCP server
    server_params = StdioServerParameters(
        command="buywhere-mcp",
        env={"BUYWHERE_API_KEY": "bw_live_your_key_here"}
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the connection
            await session.initialize()
            
            # Call the search tool
            result = await session.call_tool(
                "search",
                arguments={
                    "query": "wireless headphones",
                    "max_price": 200,
                    "limit": 5
                }
            )
            
            print(result.content[0].text)

# Run the search
asyncio.run(search_products())

Example 2: Price Comparison Function

import asyncio
from mcp import stdio_client, StdioServerParameters
from mcp.client.session import ClientSession

async def compare_product_price(product_name):
    server_params = StdioServerParameters(
        command="buywhere-mcp",
        env={"BUYWHERE_API_KEY": "bw_live_your_key_here"}
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            
            result = await session.call_tool(
                "compare_prices",
                arguments={
                    "product_name": product_name,
                    "limit": 10
                }
            )
            
            return result.content[0].text

# Example usage
price_info = asyncio.run(compare_product_price("Apple AirPods Pro"))
print(price_info)

Example 3: Building a Shopping Agent Class

import asyncio
from typing import Dict, List
from mcp import stdio_client, StdioServerParameters
from mcp.client.session import ClientSession

class BuyWhereShoppingAgent:
    def __init__(self, api_key: str):
        self.api_key = api_key
        self.server_params = StdioServerParameters(
            command="buywhere-mcp",
            env={"BUYWHERE_API_KEY": api_key}
        )
    
    async def search_and_recommend(self, query: str, max_price: float = None, 
                                 min_rating: float = None) -> List[Dict]:
        async with stdio_client(self.server_params) as (read, write):
            async with ClientSession(read, write) as session:
                await session.initialize()
                
                # Search for products
                search_result = await session.call_tool(
                    "search",
                    arguments={
                        "query": query,
                        "limit": 20
                    }
                )
                
                # In a real implementation, you would parse the structured result
                # and apply filtering logic here
                return self._parse_and_filter_results(
                    search_result.content[0].text,
                    max_price=max_price,
                    min_rating=min_rating
                )
    
    async def find_best_deal(self, product_name: str) -> Dict:
        async with stdio_client(self.server_params) as (read, write):
            async with ClientSession(read, write) as session:
                await session.initialize()
                
                result = await session.call_tool(
                    "find_deals",
                    arguments={
                        "product_name": product_name
                    }
                )
                
                return self._parse_deal_result(result.content[0].text)
    
    def _parse_and_filter_results(self, raw_text: str, max_price: float, min_rating: float) -> List[Dict]:
        # Implementation would parse the structured text response
        # and apply filters based on price and rating
        # This is a simplified placeholder
        return []
    
    def _parse_deal_result(self, raw_text: str) -> Dict:
        # Implementation would parse deal information
        return {}

# Usage example
async def main():
    agent = BuyWhereShoppingAgent("bw_live_your_key_here")
    
    # Search for gaming mice under SGD 100
    results = await agent.search_and_recommend(
        "gaming mouse", 
        max_price=100, 
        min_rating=4.0
    )
    
    print(f"Found {len(results)} gaming mice under SGD 100 with 4+ star rating")
    
    # Find best deal on a specific product
    deal = await agent.find_best_deal("Logitech MX Master 3S")
    print(f"Best deal: {deal}")

asyncio.run(main())

Real-World Use Cases

Use Case 1: Personal Shopping Assistant

Imagine having Claude as your 24/7 personal shopper that:

  • Remembers your preferences and sizes
  • Tracks price drops on items you've viewed
  • Suggests alternatives when items are out of stock
  • Helps you stay within budget while finding quality products

Use Case 2: Developer Tool Integration

Developers can integrate BuyWhere MCP into:

  • IDE extensions for quick product lookup while coding
  • CI/CD pipelines that need to purchase testing devices
  • Internal tools for office supply procurement
  • Analytics dashboards that show market trends

Use Case 3: E-commerce Research

Business analysts and researchers can use the MCP integration to:

  • Monitor competitor pricing across platforms
  • Track product availability and stock levels
  • Identify emerging trends in consumer electronics
  • Perform market research without manual data collection

Troubleshooting Common Issues

Issue 1: "MCP Server Not Responding"

Solution:

  1. Verify your API key is correct in the MCP configuration
  2. Check that the BuyWhere API is accessible: curl https://api.buywhere.ai/health
  3. Restart Claude Desktop after configuration changes
  4. Check MCP server logs: buywhere-mcp --verbose

Issue 2: "Authentication Failed"

Solution:

  1. Ensure your API key starts with bw_live_ (live key) or bw_test_ (test key)
  2. Verify the key hasn't expired in your BuyWhere developer dashboard
  3. Check that you're using the correct environment variable name (BUYWHERE_API_KEY)

Issue 3: "Tool Not Found"

Solution:

  1. Confirm you've restarted Claude Desktop after installing/configuring the MCP server
  2. Check that the MCP server is running: ps aux | grep buywhere-mcp
  3. Verify the command path in your Claude configuration is correct

Issue 4: "Slow Response Times"

Solution:

  1. The MCP server caches responses for 5 minutes to reduce API calls
  2. Consider narrowing your search queries for faster results
  3. Use specific product IDs when possible instead of broad searches
  4. Check your internet connection to the BuyWhere API servers

Best Practices for AI Shopping Assistants

1. Start Specific, Then Broaden

Begin with precise searches ("iPhone 15 Pro 256GB black") before trying broader queries ("latest smartphones").

2. Use Price Filters Wisely

Always set a maximum price unless you're doing market research - this prevents overwhelming results and focuses on your budget.

3. Leverage Cross-Platform Comparison

BuyWhere's strength is comparing prices across Singapore's major e-commerce platforms - always check multiple sources for big purchases.

4. Check Reviews and Ratings

Don't just look at price - consider the seller's rating, review count, and return policy when making purchasing decisions.

5. Consider Total Cost

Factor in shipping costs, payment method surcharges, and potential import duties when comparing final prices.

6. Use Affiliate Links Responsibly

The MCP server provides affiliate-ready tracking links - if you're building applications that generate revenue through these links, disclose this to your users.

Extending Your Shopping Assistant

Adding Voice Capabilities

Integrate with speech-to-text services to create a voice-controlled shopping assistant:

# Pseudo-code for voice integration
def voice_to_shopping():
    audio_input = listen_for_speech()
    text = speech_to_text(audio_input)
    response = claude_mcp_query(text)
    speak_response(response)

Building a Web Interface

Create a web-based shopping assistant using the same MCP principles:

// Example using fetch to call MCP endpoints (hypothetical)
async function searchBuyWhere(query) {
    const response = await fetch('/mcp/search', {
        method: 'POST',
        headers: {'Content-Type': 'application/json'},
        body: JSON.stringify({query: query, limit: 10})
    });
    return await response.json();
}

Creating Specialized Agents

Build domain-specific shopping assistants:

  • Grocery Assistant: Focus on NTUC FairPrice, Cold Storage, Sheng Siong
  • Fashion Assistant: Specialized in Zara, H&M, Uniqlo, and local boutiques
  • Electronics Engineer: Targets Mouser, Digi-Key, Arrow.com for components
  • Baby Products: Focuses on Mothercare, Babyshop, and premium brands

Conclusion

You've now built a powerful AI shopping assistant using Claude Desktop and BuyWhere's Model Context Protocol integration. This assistant can:

✅ Search products across Singapore's e-commerce platforms with natural language
✅ Compare prices to find the best deals
✅ Browse products by category
✅ Find current promotions and flash sales
✅ Generate personalized recommendations based on user needs
✅ Work programmatically through Python code for custom applications

The Model Context Protocol transforms how AI models interact with external data - instead of complex API integrations and documentation reading, AI models can now discover and use tools naturally, just like humans learn to use new applications.

Your AI shopping assistant is ready to help you save time, find better prices, and make more informed purchasing decisions across Singapore's vibrant e-commerce landscape.


Ready to build more AI-powered tools? Check out our other tutorials:

Full source code for the BuyWhere MCP server is available in the BuyWhere API repository.