This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an Amazon MCP (Model Context Protocol) Server that enables AI assistants to interact with Amazon services through web scraping. The server uses Puppeteer for browser automation and exposes Amazon functionality through MCP tools.
# Install dependencies (use -D flag for Puppeteer)
npm install -D
# Build TypeScript to JavaScript
npm run build
# Clean mock HTML files
npm run clean- MCP Server (
src/index.ts): Defines and exposes tools via the MCP protocol - Amazon Scraper (
src/amazon.ts): Contains all Amazon interaction logic using Puppeteer and Cheerio - Configuration (
src/config.ts): Manages server settings and paths - Browser Utils (
src/utils.ts): Helper functions for Puppeteer browser automation
@modelcontextprotocol/sdk: MCP frameworkpuppeteer: Browser automationcheerio: HTML parsingzod: Schema validation
The server requires Amazon cookies for authentication:
- Export cookies from browser using a cookie export extension
- Save to
amazonCookies.jsonin project root - Format: Array of cookie objects with standard properties
- Uses headless Chrome with specific flags to avoid detection
- Implements user agent spoofing
- Handles Amazon's anti-bot measures
- Detects login page redirects and throws authentication errors
- Implements retry logic for network failures
- Provides detailed error messages for debugging
- Set
USE_MOCK_RESPONSES=truein environment to use mock HTML files - Mock files stored in
mock/directory - Useful for development and testing without hitting Amazon
- Server logs to
~/Library/Logs/Claude/mcp-server-amazon.log - Check logs for debugging authentication or scraping issues
search-products: Search Amazon catalogget-product-details: Get detailed product informationget-orders-history: View past ordersget-cart-content: View current cartadd-to-cart: Add items to cartclear-cart: Remove all items from cartperform-purchase: Complete purchase (mock mode only)
No formal test suite exists. Testing is done through:
- Manual testing with Claude Desktop
- Mock mode for development
- Log analysis for debugging
- Authentication failures: Update cookies from browser
- Scraping failures: Amazon HTML structure may have changed
- Rate limiting: Add delays between requests if needed