Woo-mcp-server

Woo-mcp-server

2

The WooCommerce MCP Server is a tool designed to integrate WoCommerce stores with the Model Context Protocol using the WordPress REST API. It offers comprehensive management of products, customers, and store settings. The server provides various API methods to enhance e-commerce functionality and can be easily deployed on platforms like Railway.

🛒 WooCommerce MCP Server | Python Edition

פתרון פשוט ויעיל לחיבור חנויות WooCommerce עם Model Context Protocol

Version Python License

🇺🇸 English Version | 🇮🇱 גרסה עברית

📌 מה זה?

שרת Model Context Protocol (MCP) המאפשר אינטגרציה מלאה עם חנויות WooCommerce באמצעות ה-WordPress REST API. הספרייה מספקת כלים מקיפים לניהול כל היבטי המוצרים, הזמנות, לקוחות, משלוח, מיסים, הנחות וקונפיגורציית החנות.

🚀 התקנה מהירה

# שלב 1: שכפל את הרפוזיטורי
git clone https://github.com/yourusername/woocommerce-mcp-server.git
cd woocommerce-mcp-server

# שלב 2: התקן תלויות
pip install -r requirements.txt

# שלב 3: הגדר משתני סביבה (ראה הסבר בהמשך)

☁️ פריסה ב-Railway

השרת מוכן לפריסה מיידית בפלטפורמת Railway:

# שלב 1: שכפל את הרפוזיטורי לחשבון GitHub שלך

# שלב 2: היכנס ל-Railway והתחבר עם חשבון GitHub
# https://railway.app/

# שלב 3: לחץ על "New Project" ובחר "Deploy from GitHub repo"

# שלב 4: בחר את הרפוזיטורי המשוכפל

# שלב 5: הגדר את משתני הסביבה הבאים:
# - WORDPRESS_SITE_URL
# - WOOCOMMERCE_CONSUMER_KEY
# - WOOCOMMERCE_CONSUMER_SECRET
# - WORDPRESS_USERNAME (אופציונלי)
# - WORDPRESS_PASSWORD (אופציונלי)
# - MCP_HOST=0.0.0.0
# - MCP_PORT=8000

# שלב 6: המתן לסיום הבנייה והפריסה

יתרונות פריסה ב-Railway:

  • 🔄 פריסה אוטומטית מ-GitHub
  • 🔒 SSL אוטומטי
  • 📊 ניטור ולוגים מובנים
  • 🔍 דומיין חינמי מובנה (תת-דומיין של railway.app)
  • ⚡ סקיילינג אוטומטי לפי הצורך

⚙️ קונפיגורציה

יש ליצור קובץ .env בתיקיית הבסיס של הפרויקט עם הפרטים הבאים:

WORDPRESS_SITE_URL=https://your-wordpress-site.com
WOOCOMMERCE_CONSUMER_KEY=your-woocommerce-consumer-key
WOOCOMMERCE_CONSUMER_SECRET=your-woocommerce-consumer-secret
WORDPRESS_USERNAME=your-wordpress-username
WORDPRESS_PASSWORD=your-wordpress-password

משתני סביבה

משתנהתיאורנדרש
WORDPRESS_SITE_URLכתובת האתר שלך (WooCommerce הוא פלאגין של WordPress)
WOOCOMMERCE_CONSUMER_KEYמפתח צרכן WooCommerce REST API
WOOCOMMERCE_CONSUMER_SECRETסוד צרכן WooCommerce REST API
WORDPRESS_USERNAMEשם משתמש WordPress עם הרשאות מתאימות⚠️ *
WORDPRESS_PASSWORDסיסמת WordPress לאימות⚠️ *

* נדרש רק עבור שיטות WordPress API

🔐 אפשרויות אימות

אימות WooCommerce

גישה ל-API של WooCommerce דורשת מפתחות צרכן שניתן ליצור בלוח הבקרה של WordPress תחת WooCommerce → הגדרות → מתקדם → REST API.

אימות WordPress

עבור שיטות ספציפיות ל-WordPress (כמו ניהול פוסטים), יש לספק:

  • אישורי שם משתמש/סיסמה לאימות בסיסי
  • ה-REST API של WordPress חייב להיות מופעל באתר שלך

🔄 שיטות API

השרת תומך בשיטות API של WordPress ו-WooCommerce. להלן רשימת השיטות הזמינות מקובצות לפי קטגוריה:

ניהול תוכן WordPress

שיטות אלה דורשות אישורי שם משתמש/סיסמה של WordPress והן עצמאיות מה-API של WooCommerce.

שיטהתיאור
create_postיצירת פוסט WordPress חדש
get_postsקבלת פוסטים מ-WordPress
update_postעדכון פוסט WordPress קיים
get_post_metaקבלת מטא-דאטה של פוסט
update_post_metaעדכון מטא-דאטה של פוסט
create_post_metaיצירת מטא-דאטה של פוסט
delete_post_metaמחיקת מטא-דאטה של פוסט

מוצרי WooCommerce

שיטהתיאור
get_productsקבלת רשימת מוצרים
get_productקבלת מוצר בודד לפי מזהה
create_productיצירת מוצר חדש
update_productעדכון מוצר קיים
delete_productמחיקת מוצר
get_product_metaקבלת מטא-דאטה של מוצר
create_product_metaיצירה/עדכון מטא-דאטה של מוצר
update_product_metaעדכון מטא-דאטה של מוצר (כינוי ליצירה)
delete_product_metaמחיקת מטא-דאטה של מוצר

קטגוריות מוצרים

שיטהתיאור
get_product_categoriesקבלת קטגוריות מוצרים
get_product_categoryקבלת קטגוריית מוצר בודדת
create_product_categoryיצירת קטגוריית מוצר חדשה
update_product_categoryעדכון קטגוריית מוצר
delete_product_categoryמחיקת קטגוריית מוצר

תגיות מוצרים

שיטהתיאור
get_product_tagsקבלת תגיות מוצרים
get_product_tagקבלת תגית מוצר בודדת
create_product_tagיצירת תגית מוצר חדשה
update_product_tagעדכון תגית מוצר
delete_product_tagמחיקת תגית מוצר

מאפייני מוצרים

שיטהתיאור
get_product_attributesקבלת מאפייני מוצרים
get_product_attributeקבלת מאפיין מוצר בודד
create_product_attributeיצירת מאפיין מוצר חדש
update_product_attributeעדכון מאפיין מוצר
delete_product_attributeמחיקת מאפיין מוצר
get_attribute_termsקבלת מונחי מאפיין
get_attribute_termקבלת מונח מאפיין בודד
create_attribute_termיצירת מונח מאפיין חדש
update_attribute_termעדכון מונח מאפיין
delete_attribute_termמחיקת מונח מאפיין

וריאציות מוצרים

שיטהתיאור
get_product_variationsקבלת וריאציות מוצרים
get_product_variationקבלת וריאציית מוצר בודדת
create_product_variationיצירת וריאציית מוצר חדשה
update_product_variationעדכון וריאציית מוצר
delete_product_variationמחיקת וריאציית מוצר
batch_update_product_variationsעדכון אצווה של וריאציות מוצרים

הערות הזמנה

שיטהתיאור
get_order_notesקבלת הערות הזמנה
get_order_noteקבלת הערת הזמנה בודדת
create_order_noteיצירת הערת הזמנה חדשה
delete_order_noteמחיקת הערת הזמנה

החזרי הזמנות

שיטהתיאור
get_order_refundsקבלת החזרי הזמנות
get_order_refundקבלת החזר הזמנה בודד
create_order_refundיצירת החזר הזמנה חדש
update_order_refundעדכון החזר הזמנה
delete_order_refundמחיקת החזר הזמנה

לקוחות WooCommerce

שיטהתיאור
get_customersקבלת רשימת לקוחות
get_customerקבלת לקוח בודד לפי מזהה
create_customerיצירת לקוח חדש
update_customerעדכון לקוח קיים
delete_customerמחיקת לקוח
get_customer_metaקבלת מטא-דאטה של לקוח
create_customer_metaיצירה/עדכון מטא-דאטה של לקוח
update_customer_metaעדכון מטא-דאטה של לקוח (כינוי ליצירה)
delete_customer_metaמחיקת מטא-דאטה של לקוח

משלוח

שיטהתיאור
get_shipping_zonesקבלת אזורי משלוח
get_shipping_zoneקבלת אזור משלוח בודד
create_shipping_zoneיצירת אזור משלוח חדש
update_shipping_zoneעדכון אזור משלוח
delete_shipping_zoneמחיקת אזור משלוח
get_shipping_methodsקבלת שיטות משלוח
get_zone_shipping_methodsקבלת שיטות משלוח לאזור
get_zone_shipping_methodקבלת שיטת משלוח ספציפית לאזור
create_zone_shipping_methodיצירת שיטת משלוח חדשה לאזור
update_zone_shipping_methodעדכון שיטת משלוח לאזור
delete_zone_shipping_methodמחיקת שיטת משלוח מאזור
get_shipping_zone_locationsקבלת מיקומים לאזור משלוח
update_shipping_zone_locationsעדכון מיקומים לאזור משלוח

מיסים

שיטהתיאור
get_tax_classesקבלת קטגוריות מס
create_tax_classיצירת קטגוריית מס חדשה
delete_tax_classמחיקת קטגוריית מס
get_tax_ratesקבלת שיעורי מס
get_tax_rateקבלת שיעור מס בודד
create_tax_rateיצירת שיעור מס חדש
update_tax_rateעדכון שיעור מס
delete_tax_rateמחיקת שיעור מס
batch_update_tax_ratesעדכון אצווה של שיעורי מס

הנחות/קופונים

שיטהתיאור
get_couponsקבלת קופונים
get_couponקבלת קופון בודד
create_couponיצירת קופון חדש
update_couponעדכון קופון
delete_couponמחיקת קופון
batch_update_couponsעדכון אצווה של קופונים

שערי תשלום

שיטהתיאור
get_payment_gatewaysקבלת שערי תשלום
get_payment_gatewayקבלת שער תשלום בודד
update_payment_gatewayעדכון שער תשלום

דוחות

שיטהתיאור
get_sales_reportקבלת דוחות מכירות
get_products_reportקבלת דוחות מוצרים
get_customers_reportקבלת דוחות לקוחות
get_stock_reportקבלת דוחות מלאי

הגדרות

שיטהתיאור
get_settingsקבלת כל ההגדרות
get_setting_optionקבלת אפשרות הגדרה ספציפית
update_setting_optionעדכון אפשרות הגדרה
batch_update_settingsעדכון אצווה של הגדרות

מצב מערכת

שיטהתיאור
get_system_statusקבלת מצב מערכת
get_system_status_toolsקבלת כלי מצב מערכת
execute_system_status_toolהפעלת כלי מצב מערכת

נתונים

שיטהתיאור
get_countriesקבלת נתוני מדינות
get_country_statesקבלת מחוזות/מדינות עבור מדינה
get_currenciesקבלת נתוני מטבעות
get_currencyקבלת פרטים עבור מטבע ספציפי
get_current_currencyקבלת המטבע הנוכחי

💻 דוגמאות שימוש

אתחול שרת MCP

import os
from dotenv import load_dotenv
from woocommerce_mcp import initialize

# טעינת משתני סביבה מקובץ .env
load_dotenv()

# אתחול שרת MCP
mcp = initialize()

# הפעלת השרת
async def main():
    mcp.run()

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

דוגמה לקבלת מוצרים

import asyncio
from woocommerce_mcp.products import get_products

async def list_products():
    # קבלת המוצרים האחרונים
    products = await get_products({
        "per_page": 20, 
        "page": 1,
        "status": "publish"
    })
    
    for product in products:
        print(f"מוצר: {product['name']}, מחיר: {product['price']}")

# הפעלת הפונקציה
asyncio.run(list_products())

דוגמה ליצירת מוצר

import asyncio
from woocommerce_mcp.products import create_product

async def add_new_product():
    product_data = {
        "name": "חולצת פרימיום",
        "type": "simple",
        "regular_price": "99.99",
        "description": "חולצת כותנה נוחה, זמינה במגוון מידות וצבעים.",
        "short_description": "חולצת פרימיום באיכות גבוהה.",
        "categories": [
            {
                "id": 19
            }
        ],
        "images": [
            {
                "src": "http://example.com/wp-content/uploads/2022/06/t-shirt.jpg"
            }
        ]
    }
    
    result = await create_product(product_data)
    print(f"נוצר מוצר חדש עם מזהה: {result['id']}")

# הפעלת הפונקציה
asyncio.run(add_new_product())

📋 פרמטרים לפונקציות

כל הפונקציות מקבלות את הפרמטרים הספציפיים שלהן לפעולת ה-API, בנוסף לפרמטרים האופציונליים הבאים:

  • site_url: (אופציונלי אם מוגדר במשתני סביבה) כתובת אתר WordPress
  • consumer_key: (אופציונלי אם מוגדר במשתני סביבה) מפתח צרכן WooCommerce
  • consumer_secret: (אופציונלי אם מוגדר במשתני סביבה) סוד צרכן WooCommerce
  • עבור שיטות WordPress: username ו-password (אופציונלי אם מוגדר במשתני סביבה)

🔒 הערת אבטחה

לגישה ל-REST API של WooCommerce, עליך ליצור מפתחות API. ניתן ליצור אותם בלוח הבקרה של WordPress תחת WooCommerce → הגדרות → מתקדם → REST API.

📦 דרישות מערכת

  • Python 3.9 ומעלה
  • אתר WordPress עם פלאגין WooCommerce מותקן
  • מפתחות REST API של WooCommerce
  • חבילות Python: mcp-server, httpx, python-dotenv

📄 רישיון

MIT License - ראה קובץ LICENSE לפרטים נוספים


🛒 WooCommerce MCP Server | Python Edition

A simple and efficient solution for connecting WooCommerce stores with Model Context Protocol

Version Python License

🇮🇱 Hebrew Version | 🇺🇸 English Version

📌 What is it?

A Model Context Protocol (MCP) server for WooCommerce integration, compatible with WordPress REST API. The library provides comprehensive tools for managing all aspects of products, orders, customers, shipping, taxes, discounts, and store configuration.

🚀 Quick Installation

# Step 1: Clone the repository
git clone https://github.com/yourusername/woocommerce-mcp-server.git
cd woocommerce-mcp-server

# Step 2: Install dependencies
pip install -r requirements.txt

# Step 3: Configure environment variables (see below)

☁️ Deployment on Railway

The server is ready for immediate deployment on the Railway platform:

# Step 1: Clone the repository to your GitHub account

# Step 2: Log in to Railway and connect with your GitHub account
# https://railway.app/

# Step 3: Click on "New Project" and select "Deploy from GitHub repo"

# Step 4: Select the cloned repository

# Step 5: Configure the following environment variables:
# - WORDPRESS_SITE_URL
# - WOOCOMMERCE_CONSUMER_KEY
# - WOOCOMMERCE_CONSUMER_SECRET
# - WORDPRESS_USERNAME (optional)
# - WORDPRESS_PASSWORD (optional)
# - MCP_HOST=0.0.0.0
# - MCP_PORT=8000

# Step 6: Wait for the build and deployment to complete

Benefits of Deployment on Railway:

  • 🔄 Automatic deployment from GitHub
  • 🔒 Automatic SSL
  • 📊 Built-in monitoring and logging
  • 🔍 Free subdomain on railway.app
  • ⚡ Automatic scaling based on demand

⚙️ Configuration

Create a .env file in the project root with your credentials:

WORDPRESS_SITE_URL=https://your-wordpress-site.com
WOOCOMMERCE_CONSUMER_KEY=your-woocommerce-consumer-key
WOOCOMMERCE_CONSUMER_SECRET=your-woocommerce-consumer-secret
WORDPRESS_USERNAME=your-wordpress-username
WORDPRESS_PASSWORD=your-wordpress-password

Environment Variables

VariableDescriptionRequired
WORDPRESS_SITE_URLYour WordPress site URL (WooCommerce is a WordPress plugin)
WOOCOMMERCE_CONSUMER_KEYWooCommerce REST API consumer key
WOOCOMMERCE_CONSUMER_SECRETWooCommerce REST API consumer secret
WORDPRESS_USERNAMEWordPress username with appropriate permissions⚠️ *
WORDPRESS_PASSWORDWordPress password for authentication⚠️ *

* Required only for WordPress API methods

🔐 Authentication Options

WooCommerce Authentication

WooCommerce API access requires consumer keys that you can generate in your WordPress dashboard under WooCommerce → Settings → Advanced → REST API.

WordPress Authentication

For WordPress-specific methods (like managing posts), you need to provide:

  • Username/password credentials for basic authentication
  • The WordPress REST API must be enabled on your site

🔄 API Methods

The server supports both WordPress and WooCommerce API methods. Here's a list of available methods grouped by category:

WordPress Content Management

These methods require WordPress username/password credentials and are independent of the WooCommerce API.

MethodDescription
create_postCreate a new WordPress post
get_postsRetrieve WordPress posts
update_postUpdate an existing WordPress post
get_post_metaGet post metadata
update_post_metaUpdate post metadata
create_post_metaCreate post metadata
delete_post_metaDelete post metadata

WooCommerce Products

MethodDescription
get_productsRetrieve a list of products
get_productGet a single product by ID
create_productCreate a new product
update_productUpdate an existing product
delete_productDelete a product
get_product_metaGet product metadata
create_product_metaCreate/update product metadata
update_product_metaUpdate product metadata (alias for create)
delete_product_metaDelete product metadata

Product Categories

MethodDescription
get_product_categoriesRetrieve product categories
get_product_categoryGet a single product category
create_product_categoryCreate a new product category
update_product_categoryUpdate a product category
delete_product_categoryDelete a product category

Product Tags

MethodDescription
get_product_tagsRetrieve product tags
get_product_tagGet a single product tag
create_product_tagCreate a new product tag
update_product_tagUpdate a product tag
delete_product_tagDelete a product tag

Product Attributes

MethodDescription
get_product_attributesRetrieve product attributes
get_product_attributeGet a single product attribute
create_product_attributeCreate a new product attribute
update_product_attributeUpdate a product attribute
delete_product_attributeDelete a product attribute
get_attribute_termsRetrieve attribute terms
get_attribute_termGet a single attribute term
create_attribute_termCreate a new attribute term
update_attribute_termUpdate an attribute term
delete_attribute_termDelete an attribute term

Product Variations

MethodDescription
get_product_variationsRetrieve product variations
get_product_variationGet a single product variation
create_product_variationCreate a new product variation
update_product_variationUpdate a product variation
delete_product_variationDelete a product variation
batch_update_product_variationsBatch update product variations

Product Reviews

MethodDescription
get_product_reviewsRetrieve product reviews
get_product_reviewGet a single product review
create_product_reviewCreate a new product review
update_product_reviewUpdate a product review
delete_product_reviewDelete a product review

WooCommerce Orders

MethodDescription
get_ordersRetrieve a list of orders
get_orderGet a single order by ID
create_orderCreate a new order
update_orderUpdate an existing order
delete_orderDelete an order
get_order_metaGet order metadata
create_order_metaCreate/update order metadata
update_order_metaUpdate order metadata (alias for create)
delete_order_metaDelete order metadata

Order Notes

MethodDescription
get_order_notesRetrieve order notes
get_order_noteGet a single order note
create_order_noteCreate a new order note
delete_order_noteDelete an order note

Order Refunds

MethodDescription
get_order_refundsRetrieve order refunds
get_order_refundGet a single order refund
create_order_refundCreate a new order refund
update_order_refundUpdate an order refund
delete_order_refundDelete an order refund

WooCommerce Customers

MethodDescription
get_customersRetrieve a list of customers
get_customerGet a single customer by ID
create_customerCreate a new customer
update_customerUpdate an existing customer
delete_customerDelete a customer
get_customer_metaGet customer metadata
create_customer_metaCreate/update customer metadata
update_customer_metaUpdate customer metadata (alias for create)
delete_customer_metaDelete customer metadata

Shipping

MethodDescription
get_shipping_zonesRetrieve shipping zones
get_shipping_zoneGet a single shipping zone
create_shipping_zoneCreate a new shipping zone
update_shipping_zoneUpdate a shipping zone
delete_shipping_zoneDelete a shipping zone
get_shipping_methodsRetrieve shipping methods
get_zone_shipping_methodsGet shipping methods for a zone
get_zone_shipping_methodGet a specific shipping method for a zone
create_zone_shipping_methodCreate a new shipping method for a zone
update_zone_shipping_methodUpdate a shipping method for a zone
delete_zone_shipping_methodDelete a shipping method from a zone
get_shipping_zone_locationsGet locations for a shipping zone
update_shipping_zone_locationsUpdate locations for a shipping zone

Taxes

MethodDescription
get_tax_classesRetrieve tax classes
create_tax_classCreate a new tax class
delete_tax_classDelete a tax class
get_tax_ratesRetrieve tax rates
get_tax_rateGet a single tax rate
create_tax_rateCreate a new tax rate
update_tax_rateUpdate a tax rate
delete_tax_rateDelete a tax rate
batch_update_tax_ratesBatch update tax rates

Discounts/Coupons

MethodDescription
get_couponsRetrieve coupons
get_couponGet a single coupon
create_couponCreate a new coupon
update_couponUpdate a coupon
delete_couponDelete a coupon
batch_update_couponsBatch update coupons

Payment Gateways

MethodDescription
get_payment_gatewaysRetrieve payment gateways
get_payment_gatewayGet a single payment gateway
update_payment_gatewayUpdate a payment gateway

Reports

MethodDescription
get_sales_reportRetrieve sales reports
get_products_reportRetrieve products reports
get_customers_reportRetrieve customers reports
get_stock_reportRetrieve stock reports

Settings

MethodDescription
get_settingsRetrieve all settings
get_setting_optionRetrieve a specific setting option
update_setting_optionUpdate a setting option
batch_update_settingsBatch update settings

System Status

MethodDescription
get_system_statusRetrieve system status
get_system_status_toolsRetrieve system status tools
execute_system_status_toolRun a system status tool

Data

MethodDescription
get_countriesRetrieve countries data
get_country_statesRetrieve states/provinces for a country
get_currenciesRetrieve currencies data
get_currencyGet details for a specific currency
get_current_currencyGet the current currency

💻 Usage Examples

Initialize MCP Server

import os
from dotenv import load_dotenv
from woocommerce_mcp import initialize

# Load environment variables from .env
load_dotenv()

# Initialize the MCP server
mcp = initialize()

# Run the server
async def main():
    mcp.run()

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Example for Getting Products

import asyncio
from woocommerce_mcp.products import get_products

async def list_products():
    # Get latest products
    products = await get_products({
        "per_page": 20, 
        "page": 1,
        "status": "publish"
    })
    
    for product in products:
        print(f"Product: {product['name']}, Price: {product['price']}")

# Run the function
asyncio.run(list_products())

Example for Creating a Product

import asyncio
from woocommerce_mcp.products import create_product

async def add_new_product():
    product_data = {
        "name": "Premium T-Shirt",
        "type": "simple",
        "regular_price": "29.99",
        "description": "Comfortable cotton t-shirt, available in various sizes.",
        "short_description": "Premium quality t-shirt.",
        "categories": [
            {
                "id": 19
            }
        ],
        "images": [
            {
                "src": "http://example.com/wp-content/uploads/2022/06/t-shirt.jpg"
            }
        ]
    }
    
    result = await create_product(product_data)
    print(f"Created new product with ID: {result['id']}")

# Run the function
asyncio.run(add_new_product())

📋 Function Parameters

All functions accept their specific parameters for the API action, plus the following optional parameters:

  • site_url: (optional if set in env) WordPress site URL
  • consumer_key: (optional if set in env) WooCommerce consumer key
  • consumer_secret: (optional if set in env) WooCommerce consumer secret
  • For WordPress methods: username and password (optional if set in env)

🔒 Security Note

For WooCommerce REST API access, you need to generate API keys. You can create them in your WordPress dashboard under WooCommerce → Settings → Advanced → REST API.

📦 System Requirements

  • Python 3.9 or higher
  • WordPress site with WooCommerce plugin installed
  • WooCommerce REST API keys
  • Python packages: mcp-server, httpx, python-dotenv

📄 License

MIT License - See LICENSE file for details