woocommerce-mcp
Model-Context-Protocol to connect your store with any LLM
A powerful, modern Model-Context-Protocol (MCP) server designed to connect AI assistants with your WooCommerce store. This server provides a comprehensive set of tools to seamlessly manage orders, products, inventory, and analytics using the WooCommerce REST API. This server equips AI assistants with a robust toolkit for complete store management. This project uses uv for fast dependency management. If you don't have it, you can install it with the command below.
Summary extracted from the README.
π WooCommerce MCP Server
A powerful, modern Model-Context-Protocol (MCP) server designed to connect AI assistants with your WooCommerce store. This server provides a comprehensive set of tools to seamlessly manage orders, products, inventory, and analytics using the WooCommerce REST API.
β¨ Features
This server equips AI assistants with a robust toolkit for complete store management.
| Feature | Capabilities |
|---|---|
| π¦ Order Management | Retrieve, list, create, update, and cancel orders. You can also add and manage order notes for both internal and customer use. |
| ποΈ Product Management | Access detailed product information, list the entire catalog with filters, and create or update products. |
| π Inventory Control | Effortlessly manage stock levels with set, increase, or decrease operations, and automatically monitor for low-stock items. |
| π Analytics & Reporting | Generate detailed sales reports for any period, identify top-selling products, and get alerts for low inventory. |
| π‘ Smart Prompts | Leverage pre-configured prompts for common e-commerce workflows like processing pending orders, handling refunds, and preparing shipping batches. |
π Installation
Prerequisites
- Python 3.12 or higher
- A WooCommerce store with the REST API enabled
- WooCommerce API credentials (Consumer Key & Consumer Secret)
Setup Instructions
-
Clone the Repository
git clone https://github.com/your-username/woocommerce-mcp.git cd woocommerce-mcp -
Install Dependencies
This project uses
uvfor fast dependency management. If you don't have it, you can install it with the command below.# Install uv (if not already installed) curl -LsSf https://astral.sh/uv/install.sh | sh # Install project dependencies uv sync -
Configure Environment Variables
Create a
.envfile to store your store's credentials.# Copy the example environment file cp .env.example .env # Edit the .env file with your details nano .env -
Add Your WooCommerce Credentials
Update the
.envfile with your store's URL and API keys.WOOCOMMERCE_URL="https://your-store.com" WOOCOMMERCE_CONSUMER_KEY="ck_your_consumer_key_here" WOOCOMMERCE_CONSUMER_SECRET="cs_your_consumer_secret_here" WOOCOMMERCE_API_VERSION="v3" WOOCOMMERCE_TIMEOUT=30 DEBUG=false
How to Get WooCommerce API Credentials
- Log into your WordPress admin dashboard.
- Navigate to WooCommerce > Settings > Advanced > REST API.
- Click Add Key.
- Fill in the details:
- Description: Give the key a recognizable name (e.g., "MCP Server Access").
- User: Select an administrator user.
- Permissions: Set to Read/Write.
- Click Generate API Key.
- Copy the Consumer Key and Consumer Secret into your
.envfile.
β οΈ Important: Keep your API credentials secure. Never commit your .env file to version control.
Usage
Running the Server
You can run the MCP server directly using uv.
# Run the server using uv
uv run python -m src.woocommerce_mcp.server
# Alternatively, activate the virtual environment first
uv shell
python -m src.woocommerce_mcp.server
Available Tools
The server exposes the following tools for an AI assistant to use:
Order Management
get_order(order_id): Get details for a specific order.list_orders(status, after, before, page, per_page): List orders with optional filters.create_order(...): Create a new order with customer and product details.update_order_status(order_id, status, note, notify_customer): Update an order's status.cancel_order(order_id, reason): Cancel a specific order.add_order_note(order_id, note, notify_customer): Add a note to an order.
Product & Inventory Management
get_product(product_id): Get details for a specific product.list_products(search, category, status, page, per_page): List products with filters.create_product(name, product_type, regular_price, ...): Add a new product to the catalog.update_product(product_id, name, regular_price, ...): Modify an existing product.update_stock(product_id, quantity, operation): Manage stock levels ('set', 'increase', 'decrease').
Analytics & Reporting
get_sales_report(period, date_min, date_max): Generate a sales report.get_top_sellers(period, limit): Get a list of top-selling products.get_low_stock_products(threshold, page, per_page): Find products with low inventory.
π οΈ Development
Running Tests
To run the test suite, first install the development dependencies and then use pytest.
# Install both production and development dependencies
uv sync --dev
# Run tests
uv run pytest
# Run tests with coverage report
uv run pytest --cov=src/woocommerce_mcp
Code Quality
This project uses Ruff for linting and formatting and Pyright for type checking.
# Format code
uv run ruff format .
# Check for linting issues
uv run ruff check .
# Automatically fix linting issues
uv run ruff check . --fix
# Run static type checking
uv run pyright
π Project Structure
woocommerce-mcp/
βββ .env.example # Example environment variables
βββ .gitignore # Git ignore file
βββ pyproject.toml # Project metadata and dependencies
βββ main.py # Main entry point
βββ README.md # This file
βββ src/
βββ woocommerce_mcp/
βββ __init__.py
βββ client.py # WooCommerce API client
βββ models.py # Pydantic models for API data
βββ prompts.py # Smart prompt definitions
βββ server.py # MCP server implementation