WooCommerce MCP服务器
用于WooCommerce集成的模型上下文协议(MCP)服务器,与Windows、macOS和Linux兼容。
概述
此MCP服务器通过WordPress REST API实现与WooCommerce商店的交互。它提供了全面的工具,用于使用JSON-RPC 2.0协议管理产品、订单、客户、运输、税务、折扣和商店配置的各个方面。
相关项目
向8亿多ChatGPT用户展示您的WooCommerce商店! 结账 WooCommerce聊天GPT应用程序 -使用MCP和ChatGPT SDK构建的可视化购物助手,具有显示产品、图像、价格和描述的漂亮UI。浏览、搜索、过滤和无缝导航到您的商店-所有这些都在ChatGPT中。
安装-WooCommerce MCP服务器
克隆存储库
安装依赖项:
构建项目:
配置
将服务器添加到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访问需要消费者密钥,您可以在WooCommCommerce下的WordPress仪表板中生成这些密钥→ 设置→ 高级→ 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:(如果在env中设置,则可选)WordPress站点URL
WooCommerce方法的附加参数
consumerKey:(如果在env中设置,则可选)WooCommerce消费者密钥
consumerSecret:(如果在env中设置,则可选)WooCommerce消费者机密
WordPress方法的附加参数
username:(如果在env中设置,则可选)WordPress用户名
password:(可选,如果在env中设置)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密钥。您可以在WooCommerce下的WordPress仪表板中创建它们→ 设置→ 高级→ REST API。
需求
Node.js 20.0.0或更高版本
安装了WooCommerce插件的WordPress网站
WooCommerce REST API密钥
许可证
MIT许可证-有关详细信息,请参阅许可证文件