Shopify Storefront MCP Server

Shopify Storefront MCP Server

Seamless Shopify Storefront API access for AI assistants via Model Context Protocol

5
Stars
5
Forks
5
Watchers
2
Issues
Enables AI assistants to interact with Shopify store data through standardized MCP tools. Offers endpoints for product discovery, inventory management, GraphQL queries, cart operations, and comprehensive customer data manipulation. Designed for easy integration with MCP-compatible AI and automated token handling. Simplifies secure connection to Shopify's Storefront API with minimal configuration.

Key Features

Standardized MCP tools for Shopify Storefront access
Supports product, collection, and inventory queries
Cart creation and management
GraphQL query and mutation interface
Automatic Shopify token handling and validation
Comprehensive customer data CRUD operations
Custom field management for customer records
Seamless AI assistant compatibility
Environment variable configuration support
Discovery and authentication of Shopify storefront URLs

Use Cases

Allow AI assistants to browse and interact with Shopify product catalogs
Programmatically manage and update customer profiles and addresses
Create and modify shopping carts via automated agents
Execute secure and authenticated GraphQL queries on Shopify Storefront API
Manage customer-related data for personalized e-commerce experiences
Discover Shopify storefronts and retrieve required authentication tokens
Extend AI retail agents to perform complex store operations via MCP
Centralize storefront data access for third-party integrations
Automate inventory checks and updates through context-aware protocols
Support custom fields and loyalty program management via customer data tool

README

Shopify Storefront MCP Server

This server provides access to the Shopify Storefront API via MCP, allowing AI assistants to query and interact with your Shopify store data.

Features

  • Access to product, collection, and inventory data
  • Cart creation and management
  • Support for GraphQL queries and mutations
  • Automatic token handling and validation
  • Easy integration with MCP-compatible AI assistants

Setup Instructions

  1. Clone this repository
  2. Install dependencies: pip install -r requirements.txt
  3. Copy .env.example to .env and configure your environment variables
  4. Generate a Storefront API token via Shopify Admin (see below)
  5. Run the server: python -m shopify_storefront_mcp_server

Environment Variables

Create a .env file using the provided .env.example as a template:

# Required
SHOPIFY_STOREFRONT_ACCESS_TOKEN=your_storefront_token
SHOPIFY_STORE_NAME=your-store-name

# Optional
SHOPIFY_API_VERSION=2025-04
SHOPIFY_BUYER_IP=127.0.0.1

Generating a Storefront API Token

  1. Log in to your Shopify admin
  2. Go to Apps and sales channels > Develop apps > Create an app
  3. Name your app (e.g., "MCP Storefront")
  4. Go to API credentials > Configure Storefront API scopes
  5. Select necessary scopes:
    • unauthenticated_read_product_listings
    • unauthenticated_read_product_inventory
    • unauthenticated_read_product_pricing
    • unauthenticated_write_checkouts
    • unauthenticated_read_content
  6. Save and copy the generated Storefront API access token
  7. Add the token to your .env file as SHOPIFY_STOREFRONT_ACCESS_TOKEN

Usage Examples

Running with the MCP server:

python -m shopify_storefront_mcp_server

The server exposes the following MCP tools:

  • shopify_discover: Detect if a URL belongs to a Shopify storefront and discover authentication tokens
  • shopify_storefront_graphql: Execute GraphQL queries against the Storefront API
  • customer_data: Unified tool for all customer data operations (Create, Read, Update, Delete)

Customer Resources

This server also provides MCP resources for customer information:

  • customer://name: Customer's full name
  • customer://email: Customer's email address
  • customer://phone: Customer's phone number
  • customer://shipping_address: Customer's shipping address (including address1, address2, city, state, postal_code, country)
  • customer://billing_address: Customer's billing address (including address1, address2, city, state, postal_code, country)
  • customer://profile: Complete customer profile

Customer data is stored in user_data/customer.json and should be managed using the customer_data tool.

Managing Customer Data

The server provides a unified customer_data tool for managing all customer information. This tool consolidates create, read, update, and delete operations into a single interface.

Examples:

# Get all customer data
customer_data(operation="get")

# Get a specific field
customer_data(operation="get", field="name")
customer_data(operation="get", field="shipping_address")

# Update a specific field
customer_data(operation="update", field="name", value="Jane Doe")
customer_data(
    operation="update",
    shipping_address={
        "address1": "123 Main St",
        "address2": "Apt 4B",
        "city": "New York",
        "state": "NY",
        "postal_code": "10001",
        "country": "US"
    }
)

# Add custom fields
customer_data(
    operation="update",
    custom_fields={
        "preferences": {
            "theme": "dark",
            "notifications": "email",
            "language": "en-US"
        },
        "loyalty_tier": "gold",
        "last_purchase_date": "2023-06-15"
    }
)

# Get a custom field
customer_data(operation="get", field="preferences")
customer_data(operation="get", field="loyalty_tier")

# Update single custom field
customer_data(operation="update", field="loyalty_tier", value="platinum")

# Delete a specific field
customer_data(operation="delete", field="phone")
customer_data(operation="delete", field="preferences")

# Delete all customer data
customer_data(operation="delete")

This consolidated tool simplifies integration with AI assistants by providing a consistent interface for all customer data operations, including both standard customer information and any custom fields that may be useful for personalization.

Data Privacy & Storage

Customer data is stored in user_data/customer.json. This file contains personal information and should not be committed to version control. The repository includes:

  • user_data/customer.json.example: A template file showing the expected structure with dummy data
  • Entries in .gitignore to prevent accidental commits of actual customer data

When deploying this server, the user_data/customer.json file will be created automatically when the customer_data tool is first used. You can also copy and rename the example file to get started:

bash
cp user_data/customer.json.example user_data/customer.json

All data stored in the customer file persists between server restarts. The file supports both standard customer fields (name, email, addresses) and arbitrary custom fields for AI personalization.

Creating Checkouts with Customer Data

The server makes it easy to create Shopify checkouts that include customer information by combining the customer_data and shopify_storefront_graphql tools.

Example workflow:

# Step 1: Get customer data
customer_profile = customer_data(operation="get")

# Step 2: Create a cart with GraphQL
cart_mutation = """
mutation createCart($lines: [CartLineInput!]!) {
  cartCreate(input: {lines: $lines}) {
    cart {
      id
      checkoutUrl
    }
    userErrors {
      field
      message
    }
  }
}
"""

cart_variables = {
  "lines": [
    {
      "merchandiseId": "gid://shopify/ProductVariant/12345678901234",
      "quantity": 1
    }
  ]
}

cart_result = shopify_storefront_graphql(
  mode="execute",
  host="your-store.myshopify.com",
  token="your_storefront_token",
  query=cart_mutation,
  variables=cart_variables
)

# Step 3: Apply customer attributes to the cart
cart_id = # extract from cart_result
customer_info = json.loads(customer_profile)

attributes_mutation = """
mutation updateCartAttributes($cartId: ID!, $attributes: [AttributeInput!]!) {
  cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {
    cart {
      id
      checkoutUrl
    }
    userErrors {
      field
      message
    }
  }
}
"""

attributes_variables = {
  "cartId": cart_id,
  "attributes": [
    {
      "key": "email",
      "value": customer_info["email"]
    },
    {
      "key": "deliveryAddress",
      "value": json.dumps(customer_info["shipping_address"])
    }
  ]
}

shopify_storefront_graphql(
  mode="execute",
  host="your-store.myshopify.com",
  token="your_storefront_token",
  query=attributes_mutation,
  variables=attributes_variables
)

This approach gives you complete control over the checkout process while leveraging the stored customer information.

Troubleshooting

If you encounter authentication errors:

  1. Verify token format: Storefront API tokens should start with shpsa_ (newer) or shpat_ (older)
  2. Check store name: Ensure SHOPIFY_STORE_NAME is correct (without .myshopify.com)
  3. Check API version: Make sure the API version is supported
  4. Test token: Use cURL to test your token directly:
    curl -X POST \
      https://your-store.myshopify.com/api/2025-04/graphql.json \
      -H "Content-Type: application/json" \
      -H "X-Shopify-Storefront-Access-Token: your_token" \
      -d '{"query": "query { shop { name } }"}'
    
  5. Regenerate token: If issues persist, create a new token with proper scopes

Security Considerations

  • Never commit your .env file or any files containing API tokens
  • Use environment variables for all sensitive information
  • Consider setting up IP restrictions in your Shopify Admin
  • Review the permissions granted to your Storefront API token

Star History

Star History Chart

Repository Owner

Repository Details

Language Python
Default Branch main
Size 68 KB
Contributors 1
MCP Verified Nov 12, 2025

Programming Languages

Python
100%

Tags

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • mcp-graphql-forge

    mcp-graphql-forge

    Configuration-driven MCP server exposing modular GraphQL queries as tools.

    mcp-graphql-forge provides a lightweight, easily configurable Model Context Protocol (MCP) server that transforms any GraphQL endpoint into a set of modular API tools. Tools, defined in YAML, specify GraphQL queries and parameters to enable curated interactions via a standardized protocol. Written in Go, it emphasizes modularity, security, and extensibility without requiring code changes, and offers ready-to-run binaries for all major platforms.

    • 3
    • MCP
    • UnitVectorY-Labs/mcp-graphql-forge
  • FastMCP

    FastMCP

    The fast, Pythonic way to build MCP servers and clients.

    FastMCP is a production-ready framework for building Model Context Protocol (MCP) applications in Python. It streamlines the creation of MCP servers and clients, providing advanced features such as enterprise authentication, composable tools, OpenAPI/FastAPI generation, server proxying, deployment tools, and comprehensive client libraries. Designed for ease of use, it offers both standard protocol support and robust utilities for production deployments.

    • 20,201
    • MCP
    • jlowin/fastmcp
  • anki-mcp

    anki-mcp

    MCP server for seamless integration with Anki via AnkiConnect.

    An MCP server that bridges Anki flashcards with the Model Context Protocol, exposing AnkiConnect functionalities as standardized MCP tools. It organizes Anki actions into intuitive services covering decks, notes, cards, and models for easy access and automation. Designed for integration with AI assistants and other MCP-compatible clients, it enables operations like creating, modifying, and organizing flashcards through a unified protocol.

    • 6
    • MCP
    • ujisati/anki-mcp
  • Perplexity MCP Server

    Perplexity MCP Server

    MCP Server integration for accessing the Perplexity API with context-aware chat completion.

    Perplexity MCP Server provides a Model Context Protocol (MCP) compliant server that interfaces with the Perplexity API, enabling chat completion with citations. Designed for seamless integration with clients such as Claude Desktop, it allows users to send queries and receive context-rich responses from Perplexity. Environment configuration for API key management is supported, and limitations with long-running requests are noted. Future updates are planned to enhance support for client progress reporting.

    • 85
    • MCP
    • tanigami/mcp-server-perplexity
  • mcp-cli

    mcp-cli

    A command-line inspector and client for the Model Context Protocol

    mcp-cli is a command-line interface tool designed to interact with Model Context Protocol (MCP) servers. It allows users to run and connect to MCP servers from various sources, inspect available tools, resources, and prompts, and execute commands non-interactively or interactively. The tool supports OAuth for various server types, making integration and automation seamless for developers working with MCP-compliant servers.

    • 391
    • MCP
    • wong2/mcp-cli
  • Oura MCP Server

    Oura MCP Server

    Enables language models to access Oura sleep, readiness, and resilience data via MCP.

    Oura MCP Server implements the Model Context Protocol to provide language models with access to Oura API data. It allows querying of sleep, readiness, and resilience metrics for specified date ranges or for the current day. The server supports integration with tools like Claude for Desktop and handles API authentication and error scenarios gracefully. Designed for seamless access to personal health metrics through standardized protocol endpoints.

    • 34
    • MCP
    • tomekkorbak/oura-mcp-server
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results