WooCommerce MCP Server

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables comprehensive management of WooCommerce stores, including products, orders, customers, shipping, taxes, discounts, and store configuration through the WooCommerce REST API.

  • Provides content management capabilities for WordPress sites, including creating, retrieving, updating, and deleting posts and managing post metadata independently of WooCommerce functionality.

WooCommerce MCP 服务器

用于 WooCommerce 集成的模型上下文协议 (MCP) 服务器,兼容 Windows、macOS 和 Linux。

概述

此 MCP 服务器支持通过 WordPress REST API 与 WooCommerce 商店进行交互。它提供全面的工具,使用 JSON-RPC 2.0 协议管理产品、订单、客户、配送、税费、折扣和商店配置等各个方面。

安装

  1. 克隆存储库
  2. 安装依赖项:
npm install
  1. 构建项目:
npm run build

配置

将服务器添加到您的 MCP 设置文件中,并使用凭据的环境变量:

{ "mcpServers": { "woocommerce": { "command": "node", "args": ["path/to/build/index.js"], "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" } } } }

环境变量

WooCommerce API 访问所需:

  • WORDPRESS_SITE_URL :您的 WordPress 网站 URL(WooCommerce 是一个 WordPress 插件)
  • WOOCOMMERCE_CONSUMER_KEY :WooCommerce REST API 消费者密钥
  • WOOCOMMERCE_CONSUMER_SECRET :WooCommerce REST API 消费者机密

仅 WordPress API 方法需要:

  • WORDPRESS_USERNAME :具有适当权限的 WordPress 用户名
  • WORDPRESS_PASSWORD :用于身份验证的 WordPress 密码

如果您不想使用环境变量,您也可以在请求参数中提供这些凭据。

身份验证选项

WooCommerce 身份验证

WooCommerce API 访问需要消费者密钥,您可以在 WordPress 仪表板的 WooCommerce → 设置 → 高级 → REST API 下生成这些密钥。

WordPress 身份验证

对于 WordPress 特定的方法(例如管理帖子),您需要提供:

  • 基本身份验证的用户名/密码凭证
  • 您的网站必须启用 WordPress REST API

API 方法

该服务器支持 WordPress 和 WooCommerce API 方法。以下是按类别分组的可用方法列表:

WordPress内容管理

这些方法需要 WordPress 用户名/密码凭证,并且独立于 WooCommerce API。

方法描述
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通过ID获取单个产品
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删除产品变体

产品评论

方法描述
get_product_reviews检索产品评论
get_product_review获得单个产品评论
create_product_review创建新的产品评论
update_product_review更新产品评论
delete_product_review删除产品评论

WooCommerce 订单

方法描述
get_orders检索订单列表
get_order根据ID获取单个订单
create_order创建新订单
update_order更新现有订单
delete_order删除订单
get_order_meta获取订单元数据
create_order_meta创建/更新订单元数据
update_order_meta更新订单元数据(创建的别名)
delete_order_meta删除订单元数据

订单备注

方法描述
get_order_notes检索订单备注
get_order_note获取单个订单记录
create_order_note创建新的订单记录
delete_order_note删除订单备注

订单退款

方法描述
get_order_refunds检索订单退款
get_order_refund获得单笔订单退款
create_order_refund创建新订单退款
delete_order_refund删除订单退款

WooCommerce 客户

方法描述
get_customers检索客户列表
get_customer通过 ID 获取单个客户
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_shipping_zone_methods获取区域的运输方式
create_shipping_zone_method为区域创建新的运输方式
update_shipping_zone_method更新区域的送货方式
delete_shipping_zone_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删除税率

折扣/优惠券

方法描述
get_coupons领取优惠券
get_coupon获取一张优惠券
create_coupon创建新优惠券
update_coupon更新优惠券
delete_coupon删除优惠券

支付网关

方法描述
get_payment_gateways检索支付网关
get_payment_gateway获得单一支付网关
update_payment_gateway更新支付网关

报告

方法描述
get_sales_report检索销售报告
get_products_report检索产品报告
get_orders_report检索订单报告
get_categories_report检索类别报告
get_customers_report检索客户报告
get_stock_report检索股票报告
get_coupons_report检索优惠券报告
get_taxes_report检索税务报告

设置

方法描述
get_settings检索所有设置
get_setting_options检索设置的选项
update_setting_option更新设置选项

系统状态

方法描述
get_system_status检索系统状态
get_system_status_tools检索系统状态工具
run_system_status_tool运行系统状态工具

数据

方法描述
get_data检索商店数据
get_continents检索大洲数据
get_countries检索国家/地区数据
get_currencies检索货币数据
get_current_currency获取当前货币

方法参数

所有方法都遵循类似的参数结构。以下是一些示例:

所有方法的通用参数

  • siteUrl :(如果在环境中设置则可选)WordPress 网站 URL

WooCommerce 方法的附加参数

  • consumerKey :(如果在环境中设置则可选)WooCommerce 消费者密钥
  • consumerSecret :(如果在环境中设置则可选)WooCommerce 消费者秘密

WordPress 方法的附加参数

  • username :(如果在环境中设置则可选)WordPress 用户名
  • password :(如果在环境中设置则可选)WordPress 密码

示例用法

WordPress API 示例

{ "jsonrpc": "2.0", "id": 1, "method": "create_post", "params": { "siteUrl": "https://your-wordpress-site.com", "username": "your-wordpress-username", "password": "your-wordpress-password", "title": "My New Blog Post", "content": "This is the content of my new blog post.", "status": "publish" } }

WooCommerce 产品示例

{ "jsonrpc": "2.0", "id": 1, "method": "get_products", "params": { "perPage": 20, "page": 1, "filters": { "category": 19, "status": "publish" } } }

创建产品示例

{ "jsonrpc": "2.0", "id": 1, "method": "create_product", "params": { "productData": { "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" } ] } } }

产品元数据示例

{ "jsonrpc": "2.0", "id": 1, "method": "create_product_meta", "params": { "productId": 456, "metaKey": "_custom_product_field", "metaValue": { "special_attribute": "value", "another_attribute": 42 } } }

订单元数据示例

{ "jsonrpc": "2.0", "id": 1, "method": "create_order_meta", "params": { "orderId": 789, "metaKey": "_delivery_instructions", "metaValue": "Leave package at the back door" } }

安全说明

要访问 WooCommerce REST API,您需要生成 API 密钥。您可以在 WordPress 仪表板的 WooCommerce → 设置 → 高级 → REST API 中创建它们。

要求

  • Node.js 20.0.0 或更高版本
  • 安装了 WooCommerce 插件的 WordPress 网站
  • WooCommerce REST API 密钥

执照

MIT 许可证 - 详情请参阅许可证文件

ID: 6cg08xtbwq