Skip to main content

Shopify Store MCP 服务器

虽然官方 Shopify Dev MCP 提供开发者文档和 schema 自省,但 Store MCP 服务器 直接连接到你的 Shopify 商店的 Admin API。它们让 AI 工具执行真实操作——创建产品、获取订单、管理库存、更新客户——全部通过自然语言完成。

多个社区构建的 MCP 服务器提供商店连接功能。本指南介绍最成熟和最广泛使用的选项。

学习时使用开发商店

Store MCP 服务器在你的 Shopify 商店上执行 真实操作。像"删除所有草稿产品"这样的命令会真正删除它们。学习和测试时始终使用开发商店。在你完全理解正在执行哪些操作之前,切勿连接生产商店。

认证:访问令牌与 OAuth

在设置任何 Store MCP 服务器之前,你需要了解 Shopify 的认证模型,该模型在 2025 年 1 月发生了重大变化。

自定义应用访问令牌(旧版和现有应用)

对于 2025 年 1 月之前创建的应用,或通过 Shopify 管理后台创建的自定义应用:

  1. 进入你的 Shopify 管理后台 > 设置 > 应用和销售渠道
  2. 点击 开发应用 > 创建应用
  3. 配置 Admin API 作用域(选择你需要的权限)
  4. 安装应用并复制 Admin API 访问令牌
访问令牌格式
shpat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

OAuth 凭据(2025 年 1 月以后的新应用)

Shopify 从 2025 年 1 月开始弃用了新公共和自定义应用的直接访问令牌创建。新应用使用 OAuth 客户端凭据:

  1. 在 Shopify 合作伙伴仪表板中创建你的应用
  2. 记下你的 Client IDClient Secret
  3. 使用 OAuth 流程获取访问令牌
  4. MCP 服务器自动处理令牌刷新
你需要哪种方法?
  • 带自定义应用的开发商店:使用 访问令牌(设置更简单)
  • 通过合作伙伴仪表板创建的新应用:使用 OAuth 凭据
  • 已有令牌的现有应用:使用 现有访问令牌

大多数 MCP 服务器支持这两种方法。查看特定服务器的文档了解配置选项。

shopify-mcp(GeLi2001 开发)

最全面的社区 MCP 服务器,拥有 70 多个工具,几乎覆盖每个 Admin API 操作。这是进行完整商店管理的推荐选择。

仓库github.com/GeLi2001/shopify-mcp

为 Claude Code 安装

使用访问令牌安装
claude mcp add shopify-store -- npx -- -y shopify-mcp --accessToken shpat_your_token_here --domain your-store.myshopify.com
使用 OAuth 凭据安装
claude mcp add shopify-store -- npx -- -y shopify-mcp --clientId your_client_id --clientSecret your_client_secret --domain your-store.myshopify.com

Cursor 配置

.cursor/mcp.json
{
"mcpServers": {
"shopify-store": {
"command": "npx",
"args": [
"-y",
"shopify-mcp",
"--accessToken", "shpat_your_token_here",
"--domain", "your-store.myshopify.com"
]
}
}
}

可用操作

服务器提供按资源类型组织的工具:

产品(15 个以上工具)

工具描述
get_products列出产品,支持过滤和分页
get_product通过 ID 获取单个产品
create_product创建带变体的新产品
update_product更新产品字段
delete_product删除产品
get_product_variants列出产品的变体
create_product_variant为产品添加变体
update_product_variant修改变体详情
get_product_images列出产品图片
upload_product_image为产品添加图片
示例:创建产品
> Create a new product called "Organic Cotton T-Shirt" with sizes
S, M, L, XL. Price the small at $29.99 and add $2 for each
size up. Set inventory to 50 units per variant at our main location.

订单(10 个以上工具)

工具描述
get_orders列出订单,支持状态过滤
get_order获取带行项的单个订单
create_fulfillment履行订单
cancel_order取消订单
create_draft_order创建草稿订单
get_order_risks检查订单欺诈风险
示例:查找未履行的订单
> Show me all unfulfilled orders from the last 48 hours with
their customer email and total value.

客户(8 个以上工具)

工具描述
get_customers列出客户,支持搜索
get_customer获取客户详情
create_customer创建新客户
update_customer更新客户信息
get_customer_orders列出客户的订单
search_customers通过邮箱、姓名等搜索

产品系列(6 个以上工具)

工具描述
get_collections列出所有产品系列
get_smart_collections列出智能(自动化)产品系列
create_collection创建自定义产品系列
add_product_to_collection将产品添加到产品系列
get_collection_products列出产品系列中的产品

库存(5 个以上工具)

工具描述
get_inventory_levels检查各仓库的库存
adjust_inventory调整库存数量
get_locations列出商店位置
set_inventory_level设置绝对库存水平

折扣(6 个以上工具)

工具描述
get_price_rules列出价格规则
create_price_rule创建折扣规则
create_discount_code生成折扣码
get_discount_codes列出价格规则的折扣码

分页模式

Shopify 的 API 使用基于游标的分页。MCP 服务器会处理此问题,但了解模式有助于你发出有效的请求:

分页请求
> List all products (I have about 500). Fetch them in batches
of 50 and compile the complete list.

MCP 服务器会在后台进行多次分页 API 调用,跟踪 pageInfo.hasNextPage 并使用 endCursor 进行后续请求。

避免获取所有数据

即使 MCP 服务器处理分页,获取数千个项目也会消耗时间和 token。请具体说明:"列出最近更新的 20 个产品"比"列出所有产品"更好——当你不需要完整目录时。

@ajackus/shopify-mcp-server

另一个社区服务器,专注于简洁性和基本操作。

安装

安装 @ajackus 服务器
claude mcp add shopify-ajackus -- npx -- -y @ajackus/shopify-mcp-server --token shpat_your_token --shop your-store.myshopify.com

此服务器提供较少但精选的工具集,专注于最常见的操作。如果你想要更少的工具和更低的复杂度,这是一个不错的选择。

Python 实现

对于偏好 Python 的团队,有一个基于 Python 的 Shopify MCP 服务器:

安装 Python MCP 服务器
pip install shopify-mcp-server
Claude Desktop 配置(Python 服务器)
{
"mcpServers": {
"shopify-store": {
"command": "python",
"args": ["-m", "shopify_mcp_server"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_your_token_here",
"SHOPIFY_STORE_DOMAIN": "your-store.myshopify.com"
}
}
}
}
Python 与 Node.js MCP 服务器

两者提供类似的功能。根据你团队的语言偏好选择。Node.js 服务器(shopify-mcp、@ajackus)往往更新更频繁,因为 Shopify 自身的工具以 Node.js 为中心。如果你正在与基于 Python 的数据管道集成,Python 服务器是更好的选择。

SSE 传输配置

一些 MCP 服务器支持使用 Server-Sent Events (SSE) 作为持久 HTTP 服务运行,这对团队共享访问很有用:

使用 SSE 传输启动服务器
npx shopify-mcp --accessToken shpat_xxx --domain store.myshopify.com --transport sse --port 3100

然后配置 Claude Code 通过 SSE 连接:

Claude Code SSE 配置
{
"mcpServers": {
"shopify-store": {
"url": "http://localhost:3100/sse"
}
}
}

SSE 传输的优势

  • 多个开发者可以共享一个 MCP 服务器实例
  • 服务器保持热启动(无每次会话的启动延迟)
  • 集中管理令牌(开发者不需要各自的令牌)
  • 可以在团队服务器上部署在认证层之后

实用工作流

工作流 1:产品目录审计

审计工作流
> Analyze our product catalog:
1. List all products with no images
2. Find products with variants that have $0 price
3. Identify products with no inventory at any location
4. List products without descriptions

Compile this into a report with product titles and IDs.

工作流 2:订单调查

订单调查
> A customer (email: customer@example.com) says they haven't
received their order. Look up their recent orders, check
fulfillment status, and summarize what I should tell them.

工作流 3:批量操作

批量更新
> Add the tag "summer-2026" to all products in the "Summer
Collection" collection. Also set a metafield
custom.seasonal = "summer" on each one.

工作流 4:库存核对

库存检查
> Compare inventory levels between our "Main Warehouse" and
"Retail Store" locations. List any products where the total
across both locations is under 10 units.

安全最佳实践

最小作用域

创建访问令牌时只授予工作流所需的作用域:

工作流最小作用域
产品管理read_productswrite_products
订单查看read_orders
完整商店管理read_productswrite_productsread_orderswrite_ordersread_customersread_inventorywrite_inventory
切勿对 MCP 使用完整管理员访问权限

不要因为"以防万一"而授予所有作用域。如果你的 MCP 工作流只读取订单,只授予 read_orders。如果 MCP 服务器被入侵或误用,有限的作用域可以限制损害。在使用社区构建的服务器时这一点尤其重要。

令牌轮换

定期轮换你的访问令牌:

  1. 创建具有相同作用域的新自定义应用
  2. 使用新令牌更新 MCP 服务器配置
  3. 卸载旧的自定义应用

环境变量

永远不要在提交到版本控制的配置文件中硬编码令牌:

使用环境变量
# In your shell profile
export SHOPIFY_MCP_TOKEN=shpat_your_token_here
export SHOPIFY_MCP_DOMAIN=your-store.myshopify.com

# In Claude Code MCP configuration
claude mcp add shopify-store -- npx -- -y shopify-mcp --accessToken $SHOPIFY_MCP_TOKEN --domain $SHOPIFY_MCP_DOMAIN

故障排除

"Unauthorized" 错误

  • 验证你的访问令牌是否正确且未被撤销
  • 检查令牌是否具有操作所需的作用域
  • 确保商店域名正确(使用 .myshopify.com 域名)

速率限制

如果在批量操作期间出现速率限制错误:

受速率限制的请求
> Retry the operation with a 500ms delay between API calls.
My store is rate-limited right now.

大多数 MCP 服务器自动处理速率限制,但非常激进的批量操作可能仍会触发限制。

数据缺失

如果查询返回意外的空结果:

  • 检查产品/订单是否处于预期状态(活跃,而非草稿/已归档)
  • 验证日期范围过滤器是否使用正确格式
  • 确认访问令牌具有资源类型的 read_ 作用域

下一步

配置好商店数据访问后,你可以使用分析功能进一步增强工作流。继续学习 Analytics MCP 了解如何通过 MCP 连接 Shopify 分析和报告工具。