Skip to main content
Glama

WooCommerce MCP 服务器

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

概述

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

Related MCP server: Shopify MCP Server

安装

  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 许可证 - 详情请参阅许可证文件

-
security - not tested
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/techspawn/woocommerce-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server