Shopify Store MCP 伺服器
官方 Shopify Dev MCP 提供開發者文件和結構內省,而 store MCP 伺服器直接連接到您 Shopify 商店的 Admin API。 它們讓 AI 工具執行真實操作 -- 建立商品、擷取訂單、管理庫存、更新客戶——全部透過自然語言。
多個社群建構的 MCP 伺服器提供商店連接。本指南涵蓋最成熟和最廣泛使用的選項。
Store MCP 伺服器會在您的 Shopify 商店上執行真實操作。像「刪除所有草稿商品」這樣的命令會真正刪除它們。學習和測試時請始終使用開發商店。在您完全理解正在執行哪些操作之前,永遠不要連接生產商店。
驗證:存取權杖 vs OAuth
在設定任何 store MCP 伺服器之前,您需要了解 Shopify 的驗證模型,該模型在 2025 年 1 月發生了重大變更。
自訂應用程式存取權杖(舊有和現有應用程式)
對於 2025 年 1 月之前建立的應用程式,或透過 Shopify 管理後台建立的自訂應用程式:
- 前往 Shopify 管理後台 > 設定 > 應用程式和銷售管道
- 點擊開發應用程式 > 建立應用程式
- 設定 Admin API 範圍(選擇您需要的權限)
- 安裝應用程式並複製 Admin API 存取權杖
shpat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OAuth 憑證(2025 年 1 月以來的新應用程式)
Shopify 從 2025 年 1 月起棄用了新的公開和自訂應用程式的直接存取權杖建立方式。新應用程式使用 OAuth 客戶端憑證:
- 在 Shopify Partner Dashboard 中建立您的應用程式
- 記下您的 Client ID 和 Client Secret
- 使用 OAuth 流程取得存取權杖
- MCP 伺服器會自動處理權杖更新
- 使用自訂應用程式的開發商店:使用存取權杖(設定更簡單)
- 透過 Partner Dashboard 建立的新應用程式:使用 OAuth 憑證
- 已有儲存權杖的現有應用程式:使用現有存取權杖
大多數 MCP 伺服器支援兩種方法。請查閱特定伺服器的文件以了解設定選項。
shopify-mcp by GeLi2001
最全面的社群 MCP 伺服器,擁有 70 多個工具,涵蓋幾乎所有 Admin API 操作。這是進行完整商店管理的推薦選擇。
Repository: 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
claude mcp add shopify-store -- npx -- -y shopify-mcp --clientId your_client_id --clientSecret your_client_secret --domain your-store.myshopify.com
Cursor 設定
{
"mcpServers": {
"shopify-store": {
"command": "npx",
"args": [
"-y",
"shopify-mcp",
"--accessToken", "shpat_your_token_here",
"--domain", "your-store.myshopify.com"
]
}
}
}
可用操作
該伺服器提供按資源類型組織的工具:
Products (15+ tools)
| Tool | Description |
|---|---|
get_products | List products with filtering and pagination |
get_product | Get a single product by ID |
create_product | Create a new product with variants |
update_product | Update product fields |
delete_product | Delete a product |
get_product_variants | List variants for a product |
create_product_variant | Add a variant to a product |
update_product_variant | Modify variant details |
get_product_images | List product images |
upload_product_image | Add an image to a product |
> 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.
Orders (10+ tools)
| Tool | Description |
|---|---|
get_orders | List orders with status filters |
get_order | Get a single order with line items |
create_fulfillment | Fulfill an order |
cancel_order | Cancel an order |
create_draft_order | Create a draft order |
get_order_risks | Check order fraud risk |
> Show me all unfulfilled orders from the last 48 hours with
their customer email and total value.
Customers (8+ tools)
| Tool | Description |
|---|---|
get_customers | List customers with search |
get_customer | Get customer details |
create_customer | Create a new customer |
update_customer | Update customer info |
get_customer_orders | List a customer's orders |
search_customers | Search by email, name, etc. |
Collections (6+ tools)
| Tool | Description |
|---|---|
get_collections | List all collections |
get_smart_collections | List smart (automated) collections |
create_collection | Create a custom collection |
add_product_to_collection | Add products to a collection |
get_collection_products | List products in a collection |
Inventory (5+ tools)
| Tool | Description |
|---|---|
get_inventory_levels | Check inventory at locations |
adjust_inventory | Adjust inventory quantities |
get_locations | List store locations |
set_inventory_level | Set absolute inventory level |
Discounts (6+ tools)
| Tool | Description |
|---|---|
get_price_rules | List price rules |
create_price_rule | Create a discount rule |
create_discount_code | Generate a discount code |
get_discount_codes | List codes for a price rule |
分頁模式
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
一個替代的社群伺服器,專注於簡潔性和核心操作。
安裝
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 伺服器:
pip install shopify-mcp-server
{
"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"
}
}
}
}
兩者提供類似的功能。根據您團隊的語言偏好來選擇。Node.js 伺服器(shopify-mcp、@ajackus)往往更新頻率更高,因為 Shopify 自身的工具以 Node.js 為中心。如果您要與基於 Python 的資料管線整合,Python 伺服器是更好的選擇。
SSE 傳輸設定
部分 MCP 伺服器支援使用 Server-Sent Events (SSE) 作為持久 HTTP 服務運行,這對於團隊共享存取非常有用:
npx shopify-mcp --accessToken shpat_xxx --domain store.myshopify.com --transport sse --port 3100
然後設定 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.
安全最佳實務
範圍最小化
建立您的存取權杖時,僅包含工作流程所需的範圍:
| Workflow | Minimum Scopes |
|---|---|
| Product management | read_products, write_products |
| Order viewing | read_orders |
| Full store management | read_products, write_products, read_orders, write_orders, read_customers, read_inventory, write_inventory |
抵制「以防萬一」就授予所有範圍的誘惑。如果您的 MCP 工作流程只讀取訂單,就只授予 read_orders。如果 MCP 伺服器被入侵或濫用,有限的範圍可以限制損害。在使用社群建構的伺服器時,這一點尤為重要。
權杖輪換
定期輪換您的存取權杖:
- 建立具有相同範圍的新自訂應用程式
- 使用新權杖更新 MCP 伺服器設定
- 解除安裝舊的自訂應用程式
環境變數
永遠不要在會提交到版本控制的設定檔中硬編碼權杖:
# 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
疑難排解
「未授權」錯誤
- 驗證您的存取權杖是否正確且未被撤銷
- 檢查權杖是否具有操作所需的範圍
- 確認商店網域正確(使用
.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 分析和報告工具。