使用说明
Shopify洞察MCP
MCP Server for Shopify,提供可操作的业务洞察——比较、警报和建议,而不仅仅是数字。
演示
https://github.com/user-attachments/assets/4541bf2d-8974-4944-b3cb-4b8597d071cf
为什么存在
现有的Shopify MCP服务器返回原始数据。Shopify Insights MCP答案 “这是什么意思?” 和 “我该怎么办?”:
| 其他MCP | Shopify Insights MCP |
|---|---|
| “你的销售额为45000美元” | “你有45000美元, 减少12% 比上个月“ |
| “50个产品列表” | “有5个产品 关键库存 高需求” |
| “10个待处理订单” | “已有3个订单 5天以上未完成" |
堆栈
- TypeScript + MCP-SDK (
@modelcontextprotocol/sdk) - Shopify管理员API (GraphQL)
- 黄道带 用于输入验证
- 运输: 标准
安装
选项A:npm(推荐)
npm install -g shopify-insights-mcp
shopify-insights-mcp init
这 init 命令将指导您连接Shopify商店并生成Claude Desktop配置。
选项B:来源
git clone https://github.com/VenticinqueMauro/shopify-insights-mcp.git
cd shopify-insights-mcp
npm install
npm run build
npm run setup # Guided configuration
Shopify应用程序要求
你需要一个 自定义应用程序 使用这些范围:
read_orders,read_products,read_customers
在以下位置创建一个: Shopify管理员>设置>应用程序和销售渠道>开发应用程序
构建与运行
npm run build # Compile TypeScript → dist/
npm start # Run the MCP server (stdio)
npm run setup # Guided setup wizard
npm run inspector # Open MCP Inspector for debugging
使用Claude Desktop
快速设置(通过npx)
{
"mcpServers": {
"shopify-insights": {
"command": "npx",
"args": ["-y", "shopify-insights-mcp"],
"env": {
"SHOPIFY_SHOP_DOMAIN": "your-store.myshopify.com",
"SHOPIFY_ACCESS_TOKEN": "shpat_your_token"
}
}
}
}
本地安装
{
"mcpServers": {
"shopify-insights": {
"command": "node",
"args": ["/path/to/shopify-insights-mcp/dist/index.js"],
"env": {
"SHOPIFY_SHOP_DOMAIN": "your-store.myshopify.com",
"SHOPIFY_ACCESS_TOKEN": "shpat_your_token"
}
}
}
}
跑
shopify-insights-mcp init自动生成此配置。
然后问克劳德这样的问题:
- “这个月的销售额与上个月相比怎么样?”
- “哪些产品呈上升趋势?”
- “有什么订单需要紧急处理吗?”
- “我的客户是如何细分的?”
配置
所需的环境变量
| 变量 | 描述 |
|---|---|
SHOPIFY_SHOP_DOMAIN |
您的店铺域名(例如。, my-store.myshopify.com) |
SHOPIFY_ACCESS_TOKEN |
管理员API访问令牌(以 shpat_) |
可选环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
SHOPIFY_TIMEZONE |
从商店自动检测到 | IANA时区覆盖(例如。, America/New_York).当您的Shopify商店时区设置不正确时使用 |
SHOPIFY_API_VERSION |
2025-01 |
Shopify管理API版本 |
SHOPIFY_MAX_RECORDS |
1000 |
每次工具调用获取的最大记录数。大型商店增加 |
工具(10)
销售和收入
| 工具 | 说明 |
|---|---|
get_sales_summary |
销售汇总,包括期间与期间的比较。收入、订单、AOV、销售量 |
get_sales_comparison |
并排比较两个自定义日期范围 |
get_revenue_breakdown |
按产品、供应商或产品类型细分的收入 |
产品与库存
| 工具 | 说明 |
|---|---|
get_product_performance |
按收入、销售量或订单数对产品进行排名 |
get_inventory_alerts |
库存预警:缺货、低库存、超库检测 |
get_trending_products |
趋势产品(上涨/下跌)与上期相比 |
客户
| 工具 | 说明 |
|---|---|
get_customer_segments |
自动细分:VIP、忠诚、回归、新、非活动 |
get_top_customers |
按总支出或订单数对客户进行排名 |
运营
| 工具 | 说明 |
|---|---|
get_order_alerts |
需要注意的订单:延迟履行、财务问题、高价值待处理 |
get_fulfillment_metrics |
运营指标:完成率、财务状况、健康评分 |
建筑
src/
├── index.ts # Entry point
├── server.ts # Tool registration & request handler
├── shopify/
│ ├── auth.ts # Credentials from env vars
│ ├── client.ts # GraphQL wrapper
│ └── queries/ # Orders, products, customers queries
├── tools/
│ ├── sales/ # 3 sales tools
│ ├── products/ # 3 product tools
│ ├── customers/ # 2 customer tools
│ └── operations/ # 2 operations tools
├── analytics/
│ ├── comparisons.ts # Change calculation (%, direction)
│ ├── insights.ts # Automatic insight generation
│ └── recommendations.ts # Actionable recommendations
├── types/
│ └── shopify.ts # Shared GraphQL types
└── utils/
├── dates.ts # Period handling & date formatting
├── formatting.ts # Currency, percentage, number formatting
└── errors.ts # Standard error handling
输出示例
📊 SALES SUMMARY - THIS MONTH
CURRENT METRICS:
• Revenue: $1,245,000.00
• Orders: 234
• Avg Order Value: $5,320.51
• Units Sold: 892
VS. PREVIOUS MONTH:
• Revenue: +18.0% (+$190,000.00)
• Orders: +12.0% (+25)
• Avg Order Value: +5.4% (+$272.00)
💡 INSIGHTS:
• 📈 Revenue grew 18.0% compared to the previous period.
• 🛒 Order volume increased 12.0% (+25 orders).
📋 RECOMMENDATIONS:
• 🚀 Leverage the positive momentum by increasing investment in top-performing channels.
• 📦 Ensure sufficient stock to sustain demand growth.
测试
# Run unit tests
npm test
# Manual test via JSON-RPC over stdio
export $(grep -v '^#' .env | xargs)
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_sales_summary","arguments":{"period":"month"}}}' | node dist/index.js
# Or use MCP Inspector
npm run inspector
贡献
欢迎投稿!请随时打开问题或提交pull请求。
许可证
麻省理工学院