WooCommerce MCP Server - 通过自然语言管理 WordPress 电商商店

WooCommerce MCP Server - 通过自然语言管理 WordPress 电商商店

简介

WooCommerce MCP Server 是 WooCommerce 官方推出的 Model Context Protocol 服务器实现,为 AI 助手提供了通过自然语言管理 WordPress 电商商店的强大能力。这个服务器完整集成了 WordPress 和 WooCommerce 的 REST API,让 AI 能够轻松管理产品、订单、客户、分类、优惠券等电商核心功能。通过 JSON-RPC 2.0 协议,开发者可以让 AI 助手自动化执行商店运营任务,从产品上架到订单处理,从库存管理到营销活动配置,大幅提升电商运营效率。无论是小型独立商店还是大型电商平台,都能通过这个 MCP Server 实现智能化的商店管理。

核心特性

  • 完整的产品管理 - 创建、列出、更新、删除产品,支持简单产品和可变产品
  • 订单处理系统 - 订单创建、查询、状态更新,完整的订单生命周期管理
  • 客户管理 - 客户信息的创建、查询和维护
  • 产品分类和标签 - 灵活的产品组织结构,支持多层级分类
  • 产品属性配置 - 管理产品属性和变体
  • 配送区域设置 - 配置不同地区的配送方式和费用
  • 税收配置 - 灵活的税率设置和税务管理
  • 优惠券和折扣 - 创建和管理营销优惠活动
  • 支付网关配置 - 配置多种支付方式
  • 报表和分析 - 获取销售数据和业务洞察

工具列表

WordPress 内容管理

create_post

描述: 创建 WordPress 文章

参数:

  • title (string): 文章标题 [必需]
  • content (string): 文章内容 [必需]
  • status (string): 发布状态(publish、draft、pending 等) [可选]

产品管理工具

create_product

描述: 创建 WooCommerce 产品

参数:

  • productData (object): 产品数据对象 [必需]
    • name (string): 产品名称
    • type (string): 产品类型(simple、variable、grouped、external)
    • regular_price (string): 常规价格
    • sale_price (string): 促销价格
    • description (string): 产品描述
    • short_description (string): 简短描述
    • categories (array): 产品分类
    • tags (array): 产品标签
    • images (array): 产品图片
    • stock_quantity (number): 库存数量
    • manage_stock (boolean): 是否管理库存

list_products

描述: 列出 WooCommerce 产品

参数:

  • per_page (number): 每页返回的产品数量,默认 10 [可选]
  • page (number): 页码,默认 1 [可选]
  • search (string): 搜索关键词 [可选]
  • status (string): 产品状态(publish、draft、pending) [可选]
  • category (string): 分类过滤 [可选]

update_product

描述: 更新产品信息

参数:

  • productId (number): 产品 ID [必需]
  • productData (object): 要更新的产品数据 [必需]

delete_product

描述: 删除产品

参数:

  • productId (number): 产品 ID [必需]
  • force (boolean): 是否永久删除(默认移到回收站) [可选]

订单管理工具

create_order

描述: 创建订单

参数:

  • orderData (object): 订单数据 [必需]
    • line_items (array): 订单项目列表
      • product_id (number): 产品 ID
      • quantity (number): 数量
      • variation_id (number): 变体 ID(如果有)
    • customer_id (number): 客户 ID
    • billing (object): 账单地址
    • shipping (object): 配送地址
    • payment_method (string): 支付方式
    • payment_method_title (string): 支付方式标题

list_orders

描述: 列出订单

参数:

  • per_page (number): 每页数量 [可选]
  • page (number): 页码 [可选]
  • status (string): 订单状态(pending、processing、completed、cancelled 等) [可选]
  • customer (number): 客户 ID 过滤 [可选]

update_order

描述: 更新订单信息

参数:

  • orderId (number): 订单 ID [必需]
  • orderData (object): 要更新的订单数据 [必需]
    • status (string): 订单状态
    • billing (object): 账单地址
    • shipping (object): 配送地址

客户管理工具

create_customer

描述: 创建客户

参数:

  • customerData (object): 客户数据 [必需]
    • email (string): 客户邮箱
    • first_name (string): 名
    • last_name (string): 姓
    • username (string): 用户名
    • password (string): 密码
    • billing (object): 账单地址
    • shipping (object): 配送地址

list_customers

描述: 列出客户

参数:

  • per_page (number): 每页数量 [可选]
  • page (number): 页码 [可选]
  • search (string): 搜索关键词 [可选]
  • role (string): 用户角色过滤 [可选]

分类管理工具

create_product_category

描述: 创建产品分类

参数:

  • name (string): 分类名称 [必需]
  • parent (number): 父分类 ID [可选]
  • description (string): 分类描述 [可选]
  • image (object): 分类图片 [可选]

list_product_categories

描述: 列出产品分类

参数:

  • per_page (number): 每页数量 [可选]
  • parent (number): 父分类 ID 过滤 [可选]

营销工具

create_coupon

描述: 创建优惠券

参数:

  • couponData (object): 优惠券数据 [必需]
    • code (string): 优惠券代码
    • discount_type (string): 折扣类型(percent、fixed_cart、fixed_product)
    • amount (string): 折扣金额
    • expiry_date (string): 过期日期
    • usage_limit (number): 使用次数限制
    • minimum_amount (string): 最低消费金额

报表工具

get_reports

描述: 获取销售报表

参数:

  • reportType (string): 报表类型(sales、top_sellers、coupons_totals) [必需]
  • period (string): 时间段(week、month、last_month、year) [可选]
  • date_min (string): 开始日期 [可选]
  • date_max (string): 结束日期 [可选]

配置方式

基础配置

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"mcpServers": {
"woocommerce": {
"command": "node",
"args": ["path/to/build/index.js"],
"env": {
"WORDPRESS_SITE_URL": "https://your-wordpress-site.com",
"WOOCOMMERCE_CONSUMER_KEY": "your-consumer-key",
"WOOCOMMERCE_CONSUMER_SECRET": "your-consumer-secret"
}
}
}
}

环境变量

  • WORDPRESS_SITE_URL - WordPress 网站地址
  • WOOCOMMERCE_CONSUMER_KEY - WooCommerce API 消费者密钥
  • WOOCOMMERCE_CONSUMER_SECRET - WooCommerce API 消费者密钥密码

使用示例

系统要求

1
2
3
4
5
# 要求
- Node.js 20.0.0+
- WordPress 网站
- WooCommerce 插件(10.3+)
- WooCommerce REST API 密钥

安装步骤

1
2
3
4
5
6
7
8
9
10
# 1. 克隆仓库
git clone https://github.com/techspawn/woocommerce-mcp-server.git
cd woocommerce-mcp-server

# 2. 安装依赖和编译
npm install && npm run build

# 3. 配置环境变量
cp .env.example .env
# 编辑 .env 文件,填入你的 WordPress 站点信息

配置 REST API 密钥

1
2
3
4
5
6
7
# 在 WordPress 管理后台操作:
1. 登录 WordPress 管理后台
2. 进入 WooCommerce > 设置 > 高级 > REST API
3. 点击"添加密钥"
4. 选择用户和权限级别(建议:读/写)
5. 生成密钥后,复制 Consumer Key 和 Consumer Secret
6. 将密钥添加到配置文件中

使用场景示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// 场景 1: 创建产品
{
"jsonrpc": "2.0",
"method": "create_product",
"params": {
"productData": {
"name": "Premium Cotton T-Shirt",
"type": "simple",
"regular_price": "29.99",
"sale_price": "24.99",
"description": "High quality 100% cotton t-shirt with premium fabric",
"short_description": "Comfortable premium t-shirt",
"categories": [{"id": 9}],
"tags": [{"id": 14}],
"images": [
{"src": "https://example.com/image1.jpg"}
],
"manage_stock": true,
"stock_quantity": 100
}
}
}

// 场景 2: 创建订单
{
"jsonrpc": "2.0",
"method": "create_order",
"params": {
"orderData": {
"line_items": [
{"product_id": 123, "quantity": 2}
],
"customer_id": 1,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "123 Main St",
"city": "New York",
"state": "NY",
"postcode": "10001",
"country": "US",
"email": "[email protected]",
"phone": "555-1234"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "123 Main St",
"city": "New York",
"state": "NY",
"postcode": "10001",
"country": "US"
},
"payment_method": "stripe",
"payment_method_title": "Credit Card"
}
}
}

// 场景 3: 创建文章
{
"jsonrpc": "2.0",
"method": "create_post",
"params": {
"title": "Spring Collection Now Available",
"content": "<p>Check out our new spring collection with amazing designs!</p>",
"status": "publish"
}
}

// 场景 4: 创建优惠券
{
"jsonrpc": "2.0",
"method": "create_coupon",
"params": {
"couponData": {
"code": "SUMMER2025",
"discount_type": "percent",
"amount": "20",
"expiry_date": "2025-08-31",
"usage_limit": 100,
"minimum_amount": "50.00"
}
}
}

实际应用场景

1. AI 辅助电商运营

让 AI 助手自动化处理日常运营任务,如批量上架产品、更新库存、处理订单等,大幅减少人工操作时间。

2. 自然语言商店管理

通过自然语言指令管理商店,例如”创建一个售价 $29.99 的 T-shirt 产品”或”列出所有待处理的订单”。

3. 库存自动化

AI 监控库存水平,自动更新产品可用性,当库存低于阈值时发送警告。

4. 订单处理优化

自动化订单工作流,从订单创建到发货确认,提升订单处理效率和准确性。

5. 客户服务自动化

AI 助手自动查询订单状态、客户信息,快速响应客户咨询,提升客户满意度。

6. 营销活动管理

快速创建和管理优惠券、促销活动,AI 可以根据销售数据自动调整营销策略。

7. 数据分析和报表

AI 助手自动生成销售报表,分析销售趋势,提供业务洞察和决策建议。

技术实现

JSON-RPC 2.0 协议

采用标准的 JSON-RPC 2.0 协议进行通信,确保与各种 AI 平台的兼容性。

WordPress REST API 集成

完整支持 WordPress REST API,可以管理文章、页面、媒体等内容。

WooCommerce REST API 支持

深度集成 WooCommerce REST API,覆盖产品、订单、客户等所有电商功能。

跨平台兼容

使用 TypeScript 和 Node.js 开发,支持 Windows、macOS、Linux 等所有主流操作系统。

全面的商店管理

从产品上架到订单完成,从客户管理到营销活动,提供端到端的电商运营能力。

未来的 Agentic Commerce

计划扩展到消费者端应用,结合 Store API 实现 AI 驱动的购物和结账体验。

获取方式

相关资源

© 2026 Generative AI Discovery All Rights Reserved.
Theme by hiero