MCP 통합 패턴
이 가이드에서는 프로덕션 Shopify 워크플로우에서 MCP 서버를 사용하기 위한 고급 패턴을 다룹니다. 단일 서버 설정부터 복잡한 멀티 서버 오케스트레이션, CI/CD 통합, 자동화된 데이터 파이프라인까지 포함합니다.
패턴 1: 단일 서버 구성
가장 단순한 패턴입니다. 하나의 MCP 서버가 모든 상호작용을 처리합니다.
┌──────────┐ ┌───────────────┐ ┌─────────────┐
│ AI Client │ ──MCP──► │ shopify-mcp │ ──API──► │ Shopify Store│
│ │ │ (GeLi2001) │ │ │
└──────────┘ └───────────────┘ └─────────────┘
사용 시기:
- 단일 스토어 관리
- MCP 시작하기
- 간단한 자동화 작업
설정:
{
"mcpServers": {
"shopify": {
"command": "npx",
"args": ["-y", "shopify-mcp@latest"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_xxxxxxxxxxxxx",
"MYSHOPIFY_DOMAIN": "my-store.myshopify.com"
}
}
}
}
제한 사항:
- 문서 접근 불가 (라이브 스토어 데이터만)
- API 스키마에 대한 검증 불가
- 단일 장애 지점
패턴 2: 이중 서버 (문서 + 스토어)
대부분의 개발자에게 권장되는 패턴입니다. 문서 인텔리전스와 스토어 관리를 결합합니다.
┌──────────┐ ┌───────────────────┐
│ │────►│ Shopify Dev MCP │──► Docs, Schemas, Liquid
│ AI Client │ └───────────────────┘
│ │ ┌───────────────────┐
│ │────►│ Shopify Store MCP │──► Products, Orders, etc.
└──────────┘ └───────────────────┘
사용 시기:
- 일상적인 Shopify 개발
- 스토어를 관리하면서 앱 구축
- Shopify 플랫폼 학습
설정:
{
"mcpServers": {
"shopify-dev": {
"command": "npx",
"args": ["-y", "@anthropic-ai/shopify-dev-mcp@latest"]
},
"shopify-store": {
"command": "npx",
"args": ["-y", "shopify-mcp@latest"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_xxxxxxxxxxxxx",
"MYSHOPIFY_DOMAIN": "my-store.myshopify.com"
}
}
}
}
워크플로우 예시:
Prompt: "I need to add a 'care_instructions' metafield to all products
in the 'Apparel' collection. First, search the docs for the correct
metafield type and mutation. Then execute it on my store."
1. AI uses Dev MCP → search_docs("metafield definitions product")
2. AI uses Dev MCP → explore_api_schema("MetafieldDefinitionInput")
3. AI uses Store MCP → get_collections(type: "custom", title: "Apparel")
4. AI uses Store MCP → get_products(collection_id: "gid://...")
5. AI uses Store MCP → manage_product_metafields(product_id: "...", ...)
패턴 3: 멀티 스토어 관리
단일 AI 세션에서 여러 Shopify 스토어를 관리합니다. 에이전시, 프랜차이즈, 지역별 스토어가 있는 판매자에게 유용합니다.
┌──────────┐ ┌─────────────────────┐
│ │────►│ Store: US Production │──► us-store.myshopify.com
│ │ └─────────────────────┘
│ AI Client │ ┌─────────────────────┐
│ │────►│ Store: EU Production │──► eu-store.myshopify.com
│ │ └─────────────────────┘
│ │ ┌─────────────────────┐
│ │────►│ Store: Staging │──► staging.myshopify.com
└──────────┘ └─────────────────────┘
설정:
{
"mcpServers": {
"shopify-dev": {
"command": "npx",
"args": ["-y", "@anthropic-ai/shopify-dev-mcp@latest"]
},
"store-us": {
"command": "npx",
"args": ["-y", "shopify-mcp@latest"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_us_token",
"MYSHOPIFY_DOMAIN": "us-store.myshopify.com"
}
},
"store-eu": {
"command": "npx",
"args": ["-y", "shopify-mcp@latest"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_eu_token",
"MYSHOPIFY_DOMAIN": "eu-store.myshopify.com"
}
},
"store-staging": {
"command": "npx",
"args": ["-y", "shopify-mcp@latest"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_staging_token",
"MYSHOPIFY_DOMAIN": "staging-store.myshopify.com"
}
}
}
}
워크플로우 예시:
Prompt: "Sync the product catalog from the US store to the EU store.
For each product, convert the price from USD to EUR using a 1.08 rate
and update the description to include EU shipping information."
1. AI uses store-us → get_products(limit: 250)
2. For each product:
a. AI converts price * 1.08
b. AI uses store-eu → create_product(...) or update_product(...)
항상 스테이징에서 먼저 교차 스토어 동기화를 테스트하세요. 상품 ID는 스토어마다 다르므로 GID가 아닌 SKU, 핸들, 또는 기타 고유 식별자로 매칭해야 합니다.
패턴 4: Composio 도구 라우터
Composio는 단일 MCP 연결을 통해 여러 서비스로 도구 호출을 라우팅하는 미들웨어 레이어 역할을 합니다.
┌──────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │────►│ Shopify Admin │
│ │ │ │ └──────────────┘
│ AI Client │────►│ Composio │ ┌──────────────┐
│ │ │ Tool Router │────►│ Google Sheets │
│ │ │ │ └──────────────┘
└──────────┘ │ │ ┌──────────────┐
│ │────►│ Slack │
└──────────────┘ └──────────────┘
사용 시기:
- 여러 서비스에 걸친 워크플로우
- 원시 토큰 대신 OAuth를 원하는 경우
- 감사 요구 사항이 있는 엔터프라이즈 환경
설정:
# Install Composio
pip install composio-core
# Add integrations
composio add shopify
composio add google-sheets
composio add slack
# Optionally filter to only the tools you need
composio actions --app shopify --filter "product,order"
설정:
{
"mcpServers": {
"composio": {
"command": "composio",
"args": ["serve", "--apps", "shopify,google-sheets,slack"]
}
}
}
워크플로우 예시:
Prompt: "Every morning, pull yesterday's orders from Shopify,
summarize them in a Google Sheet, and post the summary to #sales in Slack."
1. AI uses Composio → shopify.get_orders(created_at_min: yesterday)
2. AI uses Composio → google_sheets.append_rows(spreadsheet_id, data)
3. AI uses Composio → slack.post_message(channel: "#sales", text: summary)
패턴 5: CI/CD와 MCP
배포 시 자동화된 스토어 관리를 위해 MCP 서버를 지속적 통합 파이프라인에 통합합니다.
┌──────────┐ ┌──────────┐ ┌──────────────┐ ┌─────────┐
│ Git Push │────►│ CI/CD │────►│ Claude Code │────►│ Shopify │
│ │ │ Pipeline │ │ + MCP Servers │ │ Store │
└──────────┘ └──────────┘ └──────────────┘ └─────────┘
GitHub Actions 예시
name: Shopify Store Sync
on:
push:
branches: [main]
paths:
- 'products/**'
- 'collections/**'
jobs:
sync-store:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Claude Code
run: npm install -g @anthropic-ai/claude-code
- name: Configure MCP Servers
run: |
claude mcp add shopify-store \
-e SHOPIFY_ACCESS_TOKEN=${{ secrets.SHOPIFY_ACCESS_TOKEN }} \
-e MYSHOPIFY_DOMAIN=${{ secrets.SHOP_DOMAIN }} \
-- npx -y shopify-mcp@latest
- name: Sync Products
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
claude -p "Read the product definitions in ./products/
and sync them to the Shopify store. Create new products
that don't exist, update existing ones by SKU match."
CI/CD + MCP 사용 사례
| 트리거 | 작업 | 예시 |
|---|---|---|
main에 Push | 상품 카탈로그 동기화 | Git의 상품 데이터를 단일 소스로 사용 |
| 새 릴리스 태그 | 스토어 테마 메타필드 업데이트 | 스토어에 표시되는 버전 정보 |
| 예약된 cron | 재고 수준 감사 | 일일 재고 부족 알림 |
| PR 머지 | 컬렉션 규칙 업데이트 | 코드에 정의된 컬렉션 |
| ERP Webhook | 재고 변경 동기화 | 외부 시스템 통합 |
자동화된 파이프라인은 Shopify 속도 제한에 빠르게 도달할 수 있습니다. 다음을 구현하세요:
- 429 응답에 대한 지수 백오프
- 가능한 경우 배치 작업
- 파이프라인 로그에서의 속도 제한 모니터링
패턴 6: 자동화된 스토어 관리
예약된 작업과 함께 MCP 서버를 사용하여 자동 스토어 운영을 수행합니다.
일일 상품 감사
Schedule: Every day at 6:00 AM UTC
Prompt: "Run a product catalog audit:
1. Find all products with no description
2. Find all products with no images
3. Find all products with zero inventory across all locations
4. Find all draft products older than 30 days
5. Generate a summary report with recommendations"
주간 가격 최적화
Schedule: Every Monday at 8:00 AM UTC
Prompt: "Analyze the last 7 days of orders:
1. Identify the top 20 best-selling products
2. For products with >90% sell-through, suggest a 10% price increase
3. For products with <10% sell-through and >60 days inventory, suggest a 15% discount
4. Present recommendations -- do NOT auto-apply changes"
재고 재주문 알림
Schedule: Every 4 hours
Prompt: "Check inventory levels across all locations:
1. Find variants with quantity below their reorder point (stored in metafield 'custom.reorder_point')
2. Calculate recommended reorder quantity
3. Generate a reorder list grouped by vendor"
패턴 7: 데이터 파이프라인 아키텍처
변환 및 분석 단계를 통해 Shopify 데이터를 흐르게 하는 데이터 파이프라인을 구축합니다.
┌──────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────┐
│ Shopify │ │ Extract │ │ Transform │ │ Load │
│ Store MCP │────►│ (get_orders, │────►│ (AI-powered │────►│ (Sheets, │
│ │ │ get_products)│ │ analysis) │ │ DB, CSV)│
└──────────┘ └──────────────┘ └──────────────┘ └──────────┘
추출: Shopify에서 데이터 가져오기
Prompt: "Extract all orders from the last 30 days with their line items,
customer data, and fulfillment status. Include calculated fields:
- Order value
- Number of items
- Days since order placed
- Fulfillment delay (days between order and first fulfillment)"
변환: AI 기반 분석
Prompt: "Analyze the extracted orders:
1. Customer cohort analysis (new vs returning)
2. Product affinity analysis (frequently bought together)
3. Geographic distribution of orders
4. Average order value trends by week
5. Fulfillment performance by location"
적재: 결과 출력
Prompt: "Format the analysis as:
1. A CSV file with the raw data for our data warehouse
2. A summary table for the weekly stakeholder report
3. A list of actionable recommendations"
패턴 8: 커스텀 MCP 서버 구축
기존 서버가 요구 사항을 충족하지 못할 때 커스텀 서버를 구축합니다.
최소 커스텀 서버 (TypeScript)
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new Server(
{ name: "my-shopify-tools", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// Define a custom tool
server.setRequestHandler("tools/list", async () => ({
tools: [
{
name: "calculate_shipping_estimate",
description: "Calculate estimated shipping cost based on weight and destination",
inputSchema: {
type: "object",
properties: {
weight_kg: { type: "number", description: "Package weight in kg" },
destination_country: { type: "string", description: "ISO country code" },
shipping_method: {
type: "string",
enum: ["standard", "express", "overnight"],
description: "Shipping speed"
}
},
required: ["weight_kg", "destination_country"]
}
}
]
}));
// Handle tool execution
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "calculate_shipping_estimate") {
const { weight_kg, destination_country, shipping_method } = request.params.arguments;
// Your custom business logic here
const rates = calculateRates(weight_kg, destination_country, shipping_method);
return {
content: [
{
type: "text",
text: JSON.stringify(rates, null, 2)
}
]
};
}
});
// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);
커스텀 서버 등록
# Claude Code
claude mcp add my-shopify-tools -- node /path/to/my-server/index.js
# Or with environment variables
claude mcp add my-shopify-tools \
-e SHOPIFY_ACCESS_TOKEN=xxx \
-e CUSTOM_CONFIG=value \
-- node /path/to/my-server/index.js
패턴 9: 보안 우선 구성
토큰 교체 패턴
# Store tokens in a secrets manager, not in config files
# Use a wrapper script that fetches the token at runtime
#!/bin/bash
# start-shopify-mcp.sh
export SHOPIFY_ACCESS_TOKEN=$(aws secretsmanager get-secret-value \
--secret-id shopify/production/api-token \
--query 'SecretString' --output text)
export MYSHOPIFY_DOMAIN="my-store.myshopify.com"
npx -y shopify-mcp@latest
{
"mcpServers": {
"shopify-store": {
"command": "/path/to/start-shopify-mcp.sh"
}
}
}
프로덕션 읽기 전용 접근
프로덕션 스토어의 경우 읽기 범위만 있는 토큰을 생성하세요:
Scopes: read_products, read_orders, read_customers, read_inventory
쓰기 작업에는 별도의 개발 스토어 토큰을 사용하세요.
감사 로깅
MCP 서버를 로깅 프록시로 래핑하세요:
// Log every tool call for compliance
server.setRequestHandler("tools/call", async (request) => {
const startTime = Date.now();
// Log the request
await auditLog({
timestamp: new Date().toISOString(),
tool: request.params.name,
arguments: request.params.arguments,
user: process.env.MCP_USER_ID
});
// Execute the actual tool
const result = await executeShopifyTool(request);
// Log the result
await auditLog({
timestamp: new Date().toISOString(),
tool: request.params.name,
duration_ms: Date.now() - startTime,
success: !result.isError
});
return result;
});
적합한 패턴 선택하기
| 패턴 | 복잡도 | 최적 용도 |
|---|---|---|
| 단일 서버 | 낮음 | 학습, 간단한 작업 |
| 이중 서버 (문서 + 스토어) | 낮음 | 일상적인 개발 |
| 멀티 스토어 | 중간 | 에이전시, 프랜차이즈 |
| Composio 라우터 | 중간 | 크로스 서비스 워크플로우 |
| CI/CD 통합 | 높음 | 자동화된 배포 |
| 자동화된 관리 | 높음 | 예약된 작업 |
| 데이터 파이프라인 | 높음 | 분석, 리포팅 |
| 커스텀 서버 | 높음 | 고유한 비즈니스 로직 |
| 보안 우선 | 중간 | 프로덕션 환경 |
패턴 2 (이중 서버)로 시작하세요. MCP 상호작용에 익숙해지면 워크플로우가 요구하는 대로 복잡도를 추가하세요. 대부분의 개발자는 패턴 2-3 이상이 필요하지 않습니다.