WooCommerce-MCP-Server

faizan45640/WooCommerce-MCP-Server

3.2

If you are the rightful owner of WooCommerce-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

WooCommerce-MCP-Server is a server implementation designed to facilitate communication between WooCommerce and various model context protocols.

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

  1. Clone the repository:
git clone https://github.com/faizan45640/WooCommerce-MCP-Server.git
cd WooCommerce-MCP-Server
  1. Install dependencies:
npm install
  1. Create a .env file with your WooCommerce credentials:
WOOCOMMERCE_URL=https://your-store.com
WOOCOMMERCE_CONSUMER_KEY=your_consumer_key
WOOCOMMERCE_CONSUMER_SECRET=your_consumer_secret
  1. Start the server:
npm start

Usage

Development

npm run dev

Production

npm start

Configuration

Create a .env file in the root directory with the following variables:

# 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:

{
  "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

npm test

Linting

npm run lint
npm run lint:fix

Environment Variables

VariableDescriptionDefaultRequired
WOOCOMMERCE_URLYour WooCommerce store URL-Yes
WOOCOMMERCE_CONSUMER_KEYAPI Consumer Key-Yes
WOOCOMMERCE_CONSUMER_SECRETAPI Consumer Secret-Yes
WOOCOMMERCE_API_VERSIONAPI Versionv3No
LOG_LEVELLogging levelinfoNo
MCP_SERVER_PORTServer port3000No

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

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests
  4. Run tests: npm test
  5. Commit your changes: git commit -am 'Add feature'
  6. Push to the branch: git push origin feature-name
  7. Submit a pull request

License

This project is licensed under the MIT License - see the 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