Shopify MCP Server 是一个用于 Shopify API 的服务器,它允许用户通过 GraphQL API 与店铺数据进行交互。该服务器提供了管理产品、客户、订单等功能的工具。
如果你喜欢这个项目,欢迎留下一个 Star!
📦 包名:shopify-mcp
🚀 命令:shopify-mcp(不是 shopify-mcp-server)
要使用这个 MCP 服务器,你需要在你的 Shopify 商店中创建一个自定义应用,并获取访问令牌。具体步骤如下:
read_products, write_productsread_customers, write_customersread_orders, write_ordersread_content, write_content(用于博客和文章)将以下内容添加到你的 claude_desktop_config.json 文件中:
{
"mcpServers": {
"shopify": {
"command": "npx",
"args": [
"shopify-mcp",
"--accessToken",
"" ,
"--domain",
".myshopify.com"
]
}
}
}
Claude Desktop 配置文件的位置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%/Claude/claude_desktop_config.json如果你更喜欢使用环境变量而不是命令行参数,可以按照以下步骤操作:
.env 文件,并包含你的 Shopify 凭证:SHOPIFY_ACCESS_TOKEN=your_access_token
MYSHOPIFY_DOMAIN=your-store.myshopify.com
npx shopify-mcp
如果你想全局安装该包,可以使用以下命令:
npm install -g shopify-mcp
然后运行它:
shopify-mcp --accessToken= --domain=.myshopify.com
⚠️ 重要提示
如果你在使用命令行参数时看到 “SHOPIFY_ACCESS_TOKEN environment variable is required” 错误,可能是你安装了不同的包。请确保你使用的是
shopify-mcp,而不是shopify-mcp-server。
要使用此 MCP 服务器,你需要在你的 Shopify 商店中创建一个自定义应用:
read_products, write_productsread_customers, write_customersread_orders, write_ordersread_content, write_content(用于博客和文章)get-products获取产品或按标题搜索产品,支持基于游标导航的分页。
// 获取第一页产品
{
"limit": 10
}
// 使用上一个响应中的 endCursor 获取下一页
{
"limit": 10,
"after": "endCursor_from_previous_response"
}
// 使用当前响应中的 startCursor 获取上一页
{
"limit": 10,
"before": "startCursor_from_current_response"
}
// 带分页的产品搜索
{
"searchTitle": "t-shirt",
"limit": 5,
"after": "cursor_from_previous_response"
}
// 以相反顺序获取产品
{
"limit": 10,
"reverse": true
}
get-product-by-id按 ID 获取特定产品的所有详细信息。
{
"productId": "gid://shopify/Product/1234567890"
}
update-product更新产品的任何方面,包括基本信息、SEO 和变体。
// 更新产品标题和状态
{
"productId": "gid://shopify/Product/1234567890",
"title": "Awesome T-Shirt",
"status": "ACTIVE"
}
// 更新 SEO 信息
{
"productId": "gid://shopify/Product/1234567890",
"seo": {
"title": "Awesome T-Shirt | 100% Cotton | Available in 5 Colors",
"description": "High-quality cotton t-shirt perfect for everyday wear. Available in multiple colors and sizes."
}
}
// 更新产品变体
{
"productId": "gid://shopify/Product/1234567890",
"variants": [
{
"id": "gid://shopify/ProductVariant/1234567",
"price": "29.99",
"compareAtPrice": "39.99",
"inventoryPolicy": "DENY"
}
]
}
// 一次性更新多个方面
{
"productId": "gid://shopify/Product/1234567890",
"title": "Premium Cotton T-Shirt",
"vendor": "Fashion Basics",
"productType": "Apparel",
"tags": ["cotton", "t-shirt", "basics", "summer"],
"seo": {
"title": "Premium Cotton T-Shirt | Fashion Basics | Multiple Colors",
"description": "Experience comfort with our premium cotton t-shirt. Perfect for any occasion."
},
"variants": [
{
"id": "gid://shopify/ProductVariant/1234567",
"price": "29.99",
"compareAtPrice": "39.99"
}
]
}
update-product-image-alt-text更新特定产品图片的替代文本。
{
"productId": "gid://shopify/Product/1234567890",
"imageId": "gid://shopify/MediaImage/123",
"altText": "New alt text for the image"
}
create-article在指定博客中创建新文章。
// 创建一篇已发布的文章,包含格式化内容
{
"blogId": "gid://shopify/Blog/123456789",
"title": "My New Article",
"content": "Article content with HTML formatting.
",
"author": {
"name": "John Doe"
},
"published": true,
"tags": ["news", "updates"]
}
// 创建一篇草稿文章,用于未来发布
{
"blogId": "gid://shopify/Blog/123456789",
"title": "Upcoming Article",
"content": "Draft content...
",
"author": {
"name": "Jane Smith"
},
"published": false,
"tags": ["draft"]
}
search-shopify对产品、文章、博客和页面进行统一搜索。
// 搜索关于 "kawaii" 的文章和博客
{
"query": "kawaii",
"types": ["ARTICLE", "BLOG"],
"first": 5
}
// 搜索所有内容类型
{
"query": "new collection",
"first": 10
}
update-page更新现有页面的详细信息。
// 更新页面内容和 SEO
{
"pageId": "gid://shopify/Page/123456789",
"title": "About Our Store",
"bodyHtml": "Welcome!
Learn about our story...
",
"seo": {
"title": "About Us - Kawaii Store",
"description": "Discover our journey in bringing kawaii culture to you"
}
}
update-collection更新现有集合的详细信息。
// 更新集合并进行 SEO 优化
{
"collectionId": "gid://shopify/Collection/123456789",
"title": "Summer Kawaii Collection",
"descriptionHtml": "Discover our cutest summer items!
",
"seo": {
"title": "Summer Kawaii Collection 2025",
"description": "Explore our adorable summer collection featuring..."
}
}
所有工具都包含全面的错误处理,包括:
错误响应包括:
get-blogs 获取有效的博客 ID。get-blog-by-id 获取特定博客的详细信息。commentPolicy 只能设置为 "MODERATED" 或 "CLOSED"。get-articles 列出特定博客中的文章。body 字段支持 HTML 内容。
、
、
等)。published: false 以保存而不发布。content 字段接受 HTML 标记以实现丰富的格式:<p>First paragraph with <strong>bold textstrong>.p>
<h2>Section Headingh2>
<ul>
<li>List item oneli>
<li>List item twoli>
ul>
"tags": ["product-updates", "how-to", "tips"]
published: false 创建未发布的草稿:{
"published": false,
// 其他字段...
}
"author": {
"name": "Full Author Name"
}