Skip to main content

MCP Integration Patterns

This guide covers advanced patterns for using MCP servers in production Shopify workflows. From single-server setups to complex multi-server orchestration, CI/CD integration, and automated data pipelines.


Pattern 1: Single Server Configuration

The simplest pattern. One MCP server handles all interactions.

┌──────────┐          ┌───────────────┐          ┌─────────────┐
│ AI Client │ ──MCP──► │ shopify-mcp │ ──API──► │ Shopify Store│
│ │ │ (GeLi2001) │ │ │
└──────────┘ └───────────────┘ └─────────────┘

When to use:

  • Single store management
  • Getting started with MCP
  • Simple automation tasks

Configuration:

{
"mcpServers": {
"shopify": {
"command": "npx",
"args": ["-y", "shopify-mcp@latest"],
"env": {
"SHOPIFY_ACCESS_TOKEN": "shpat_xxxxxxxxxxxxx",
"MYSHOPIFY_DOMAIN": "my-store.myshopify.com"
}
}
}
}

Limitations:

  • No documentation access (only live store data)
  • Cannot validate against API schemas
  • Single point of failure

Pattern 2: Dual Server (Docs + Store)

The recommended pattern for most developers. Combines documentation intelligence with store management.

┌──────────┐     ┌───────────────────┐
│ │────►│ Shopify Dev MCP │──► Docs, Schemas, Liquid
│ AI Client │ └───────────────────┘
│ │ ┌───────────────────┐
│ │────►│ Shopify Store MCP │──► Products, Orders, etc.
└──────────┘ └───────────────────┘

When to use:

  • Day-to-day Shopify development
  • Building apps while managing a store
  • Learning the Shopify platform

Configuration:

{
"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"
}
}
}
}

Example workflow:

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: "...", ...)

Pattern 3: Multi-Store Management

Manage multiple Shopify stores from a single AI session. Useful for agencies, franchises, and merchants with regional stores.

┌──────────┐     ┌─────────────────────┐
│ │────►│ Store: US Production │──► us-store.myshopify.com
│ │ └─────────────────────┘
│ AI Client │ ┌─────────────────────┐
│ │────►│ Store: EU Production │──► eu-store.myshopify.com
│ │ └─────────────────────┘
│ │ ┌─────────────────────┐
│ │────►│ Store: Staging │──► staging.myshopify.com
└──────────┘ └─────────────────────┘

Configuration:

{
"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"
}
}
}
}

Example workflow:

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(...)
Cross-Store Operations

Always test cross-store sync on staging first. Product IDs differ between stores, so you must match by SKU, handle, or other unique identifier -- not by GID.


Pattern 4: Composio Tool Router

Composio acts as a middleware layer that routes tool calls to multiple services through a single MCP connection.

┌──────────┐     ┌──────────────┐     ┌──────────────┐
│ │ │ │────►│ Shopify Admin │
│ │ │ │ └──────────────┘
│ AI Client │────►│ Composio │ ┌──────────────┐
│ │ │ Tool Router │────►│ Google Sheets │
│ │ │ │ └──────────────┘
└──────────┘ │ │ ┌──────────────┐
│ │────►│ Slack │
└──────────────┘ └──────────────┘

When to use:

  • Workflows that span multiple services
  • You want OAuth instead of raw tokens
  • Enterprise environments with audit requirements

Setup:

# 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"

Configuration:

{
"mcpServers": {
"composio": {
"command": "composio",
"args": ["serve", "--apps", "shopify,google-sheets,slack"]
}
}
}

Example workflow:

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)

Pattern 5: CI/CD with MCP

Integrate MCP servers into your continuous integration pipeline for automated store management on deploy.

┌──────────┐     ┌──────────┐     ┌──────────────┐     ┌─────────┐
│ Git Push │────►│ CI/CD │────►│ Claude Code │────►│ Shopify │
│ │ │ Pipeline │ │ + MCP Servers │ │ Store │
└──────────┘ └──────────┘ └──────────────┘ └─────────┘

GitHub Actions Example

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."

Use Cases for CI/CD + MCP

TriggerActionExample
Push to mainSync product catalogProduct data in Git as source of truth
New release tagUpdate store theme metafieldsVersion info displayed in store
Scheduled cronAudit inventory levelsDaily low-stock alerts
PR mergedUpdate collection rulesCollection definitions in code
Webhook from ERPSync inventory changesExternal system integration
Rate Limits in CI/CD

Automated pipelines can hit Shopify rate limits quickly. Implement:

  • Exponential backoff on 429 responses
  • Batch operations where possible
  • Rate limit monitoring in your pipeline logs

Pattern 6: Automated Store Management

Use MCP servers with scheduled tasks for hands-off store operations.

Daily Product Audit

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"

Weekly Price Optimization

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"

Inventory Reorder Alerts

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"

Pattern 7: Data Pipeline Architecture

Build data pipelines that flow Shopify data through transformation and analysis stages.

┌──────────┐     ┌──────────────┐     ┌──────────────┐     ┌──────────┐
│ Shopify │ │ Extract │ │ Transform │ │ Load │
│ Store MCP │────►│ (get_orders, │────►│ (AI-powered │────►│ (Sheets, │
│ │ │ get_products)│ │ analysis) │ │ DB, CSV)│
└──────────┘ └──────────────┘ └──────────────┘ └──────────┘

Extract: Pull Data from 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)"

Transform: AI-Powered Analysis

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"

Load: Output Results

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"

Pattern 8: Building Custom MCP Servers

When existing servers do not cover your needs, build a custom one.

Minimal Custom Server (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);

Register Your Custom Server

# 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

Pattern 9: Security-First Configuration

Token Rotation Pattern

# 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"
}
}
}

Read-Only Production Access

For production stores, create a token with only read scopes:

Scopes: read_products, read_orders, read_customers, read_inventory

Use a separate development store token for write operations.

Audit Logging

Wrap your MCP server with a logging proxy:

// 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;
});

Choosing the Right Pattern

PatternComplexityBest For
Single ServerLowLearning, simple tasks
Dual Server (Docs + Store)LowDay-to-day development
Multi-StoreMediumAgencies, franchises
Composio RouterMediumCross-service workflows
CI/CD IntegrationHighAutomated deployments
Automated ManagementHighScheduled operations
Data PipelinesHighAnalytics, reporting
Custom ServerHighUnique business logic
Security-FirstMediumProduction environments
Start Simple, Scale Up

Begin with Pattern 2 (Dual Server). Once you are comfortable with MCP interactions, add complexity as your workflows demand. Most developers never need more than Patterns 2-3.