Guides
The Model Context Protocol (MCP) is Anthropic's standard for connecting Claude to external tools and data sources. This guide shows how to create an MCP server for your e-commerce store.
MCP allows Claude Desktop to:
1npm install @commercegateway/commerce-gateway1import { MCPServer } from '@commercegateway/commerce-gateway/mcp';2import { MyBackend } from './backend';3 4const server = new MCPServer({5 backends: {6 products: new MyBackend(),7 cart: new MyBackend(),8 },9 tools: [10 'search_products',11 'get_product_details', 12 'add_to_cart',13 'check_inventory',14 'get_recommendations',15 'create_order',16 ],17 resources: ['catalog'],18 prompts: ['shopping_assistant'],19 name: 'my-store',20 version: '1.0.0',21});22 23server.start();Add to ~/.config/claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
1{2 "mcpServers": {3 "my-store": {4 "command": "node",5 "args": ["/absolute/path/to/mcp-server.js"],6 "env": {7 "REDIS_URL": "redis://localhost:6379",8 "API_KEY": "your-api-key"9 }10 }11 }12}Close and reopen Claude Desktop. Your tools should now be available!
The gateway includes 6 commerce tools out of the box:
| Tool | Description |
|------|-------------|
| search_products | Search product catalog with filters |
| get_product_details | Get detailed product info by ID |
| add_to_cart | Add item to shopping cart |
| check_inventory | Check stock availability |
| get_recommendations | Get product recommendations |
| create_order | Create order from cart |
User asks about products
"What wireless headphones do you have?"
Claude calls search_products with query "wireless headphones"
Claude shows results
"I found 3 wireless headphones:
Premium Wireless Headphones - $299.99 ⭐ 4.8/5 Active noise cancellation, 30-hour battery
Sport Earbuds - $149.99 ⭐ 4.6/5 Water resistant, 8-hour battery
Would you like details on any of these?"
User adds to cart
"Add the Premium headphones in black to my cart"
Claude calls add_to_cart with product ID and variant
claude_desktop_config.json is absolutenode /path/to/mcp-server.jsYour backend might be throwing errors. Add logging to your terminal output and check there.
