WooCommerce MCP Server
A Model Context Protocol (MCP) server for seamless WooCommerce integration, enabling AI assistants to interact with your WooCommerce store through natural language.
Features
- Product Management: Create, read, update, and delete products with full support for variations, categories, and attributes
- Order Processing: Retrieve and manage orders, update order statuses, and handle order fulfillment
- Customer Management: Access customer data, manage customer accounts, and view purchase history
- Inventory Control: Monitor stock levels, update inventory, and manage product availability
- Analytics & Reporting: Access store analytics, sales reports, and performance metrics
- Category & Tag Management: Organize products with categories and tags
- Coupon Management: Create and manage discount codes and promotional offers
- Store Configuration: Access and modify store settings and configuration options
Installation
- Clone the repository:```bash
git clone https://github.com/faizan45640/WooCommerce-MCP-Server.git
cd WooCommerce-MCP-Server
2. Install dependencies:```bash
npm install
- Create a
.envfile with your WooCommerce credentials:```env
WOOCOMMERCE_URL=https://your-store.com
WOOCOMMERCE_CONSUMER_KEY=your_consumer_key
WOOCOMMERCE_CONSUMER_SECRET=your_consumer_secret
4. Start the server:```bash
npm start
Usage
Development```bash
npm run dev
### Production```bash
npm start
Configuration
Create a .env file in the root directory with the following variables:```env
WooCommerce Store Configuration
WOOCOMMERCE_URL=https://your-store.com
WOOCOMMERCE_CONSUMER_KEY=your_consumer_key
WOOCOMMERCE_CONSUMER_SECRET=your_consumer_secret
WOOCOMMERCE_API_VERSION=v3
MCP Server Configuration
MCP_SERVER_PORT=3000
LOG_LEVEL=info
## Getting WooCommerce API Credentials
1. Go to your WordPress admin dashboard
2. Navigate to WooCommerce → Settings → Advanced → REST API
3. Click "Add Key"
4. Set Description (e.g., "MCP Server")
5. Select User and Permissions (Read/Write recommended)
6. Click "Generate API Key"
7. Copy the Consumer Key and Consumer Secret to your `.env` file
## Available Tools
The MCP server provides the following tools:
### Products
- `get_products` - Retrieve products with filtering options
- `get_product` - Get a specific product by ID
- `create_product` - Create a new product
- `update_product` - Update an existing product
- `delete_product` - Delete a product
- `search_products` - Search products by term
- `get_product_categories` - Get product categories
### Orders
- `get_orders` - Retrieve orders with filtering options
- `get_order` - Get a specific order by ID
- `create_order` - Create a new order
- `update_order` - Update order details
- `update_order_status` - Update order status
- `get_recent_orders` - Get recent orders
- `get_order_stats` - Get order statistics
- `add_order_note` - Add notes to orders
### Customers
- `get_customers` - Retrieve customer list
- `get_customer` - Get specific customer details
- `create_customer` - Create a new customer
- `update_customer` - Update customer information
- `search_customers` - Search customers
- `get_customer_by_email` - Find customer by email
- `get_customer_orders` - Get customer's orders
- `get_customer_stats` - Get customer statistics
- `get_top_customers` - Get top spending customers
- `get_new_customers` - Get recently registered customers
### Inventory
- `check_stock` - Check product stock levels
- `update_stock` - Update product inventory
- `get_low_stock_products` - Get products with low stock
- `get_out_of_stock_products` - Get out-of-stock products
- `get_stock_report` - Get comprehensive stock report
- `bulk_update_stock` - Update multiple products' stock
## Example Usage with Claude Desktop
Add this server to your Claude Desktop configuration:```json
{
"mcpServers": {
"woocommerce": {
"command": "node",
"args": ["path/to/WooCommerce-MCP-Server/src/index.js"]
}
}
}
Then you can interact with your WooCommerce store using natural language:
- "Show me the top 10 products by sales"
- "Create a new product called 'Premium T-Shirt' priced at $25"
- "Update order #123 status to 'completed'"
- "List all customers who made purchases this month"
- "Check which products are running low on stock"
- "Get me a summary of today's orders"
Development
Project Structure```
src/
├── index.js # Main server entry point
├── services/
│ ├── woocommerce.js # WooCommerce API client
│ ├── products.js # Product management service
│ ├── orders.js # Order management service
│ └── customers.js # Customer management service
├── tools/
│ ├── index.js # Tool registry
│ ├── products/ # Product-related tools
│ ├── orders/ # Order-related tools
│ ├── customers/ # Customer-related tools
│ └── inventory/ # Inventory-related tools
└── utils/
├── validation.js # Input validation utilities
└── logger.js # Logging utilities
tests/ # Test files
### Running Tests```bash
npm test
Linting```bash
npm run lint
npm run lint:fix
```
Environment Variables
| Variable | Description | Default | Required |
|---|---|---|---|
WOOCOMMERCE_URL |
Your WooCommerce store URL | - | Yes |
WOOCOMMERCE_CONSUMER_KEY |
API Consumer Key | - | Yes |
WOOCOMMERCE_CONSUMER_SECRET |
API Consumer Secret | - | Yes |
WOOCOMMERCE_API_VERSION |
API Version | v3 |
No |
LOG_LEVEL |
Logging level | info |
No |
MCP_SERVER_PORT |
Server port | 3000 |
No |
Error Handling
The server includes comprehensive error handling:
- Input validation for all tool parameters
- WooCommerce API error responses
- Connection and timeout handling
- Detailed error logging
Security
- Uses OAuth 1.0a for secure API authentication
- Input validation to prevent injection attacks
- No sensitive data in logs
- Environment variable configuration
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests
- Run tests:
npm test - Commit your changes:
git commit -am 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please open an issue on the GitHub repository.
Roadmap
- [ ] Support for WooCommerce Subscriptions
- [ ] Advanced reporting and analytics
- [ ] Bulk operations for products and orders
- [ ] Integration with payment gateways
- [ ] Multi-store support
- [ ] Webhook support for real-time updates
- [ ] GraphQL API support
- [ ] Rate limiting and caching
- [ ] Docker containerization
